Skip to content

Commit e01a75a

Browse files
feat(api): manual updates
1 parent 2d41187 commit e01a75a

File tree

8 files changed

+541
-57
lines changed

8 files changed

+541
-57
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml
3-
openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
3+
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
44
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29

image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
package com.imagekit.api.models.files
44

5-
import com.imagekit.api.core.JsonValue
65
import com.imagekit.api.core.Params
76
import com.imagekit.api.core.checkRequired
87
import com.imagekit.api.core.http.Headers
@@ -84,7 +83,7 @@ private constructor(
8483
* Alias for calling [updateFileRequest] with
8584
* `UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus)`.
8685
*/
87-
fun updateFileRequest(changePublicationStatus: JsonValue) =
86+
fun updateFileRequest(changePublicationStatus: UpdateFileRequest.ChangePublicationStatus) =
8887
updateFileRequest(UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus))
8988

9089
fun additionalHeaders(additionalHeaders: Headers) = apply {

image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt

Lines changed: 381 additions & 9 deletions
Large diffs are not rendered by default.

image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ internal class FileUpdateParamsTest {
1515
.fileId("fileId")
1616
.updateFileRequest(
1717
UpdateFileRequest.UpdateFileDetails.builder()
18-
.customCoordinates("customCoordinates")
18+
.customCoordinates("10,10,100,100")
1919
.customMetadata(
2020
UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder()
21-
.putAdditionalProperty("foo", JsonValue.from("bar"))
21+
.putAdditionalProperty("brand", JsonValue.from("bar"))
22+
.putAdditionalProperty("color", JsonValue.from("bar"))
2223
.build()
2324
)
2425
.description("description")
@@ -38,20 +39,31 @@ internal class FileUpdateParamsTest {
3839
),
3940
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
4041
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
41-
.maxTags(5L)
42-
.minConfidence(95L)
42+
.maxTags(10L)
43+
.minConfidence(80L)
4344
.name(
4445
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name
4546
.GOOGLE_AUTO_TAGGING
4647
)
4748
.build()
4849
),
50+
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
51+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
52+
.maxTags(10L)
53+
.minConfidence(80L)
54+
.name(
55+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name
56+
.AWS_AUTO_TAGGING
57+
)
58+
.build()
59+
),
4960
UnnamedSchemaWithArrayParent1.ofAiAutoDescription(),
5061
)
5162
)
52-
.removeAiTagsOfStrings(listOf("string"))
53-
.tags(listOf("car", "vehicle", "motorsports"))
54-
.webhookUrl("https://example.com")
63+
.removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports"))
64+
.addTag("tag1")
65+
.addTag("tag2")
66+
.webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a")
5567
.build()
5668
)
5769
.build()
@@ -77,10 +89,11 @@ internal class FileUpdateParamsTest {
7789
.fileId("fileId")
7890
.updateFileRequest(
7991
UpdateFileRequest.UpdateFileDetails.builder()
80-
.customCoordinates("customCoordinates")
92+
.customCoordinates("10,10,100,100")
8193
.customMetadata(
8294
UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder()
83-
.putAdditionalProperty("foo", JsonValue.from("bar"))
95+
.putAdditionalProperty("brand", JsonValue.from("bar"))
96+
.putAdditionalProperty("color", JsonValue.from("bar"))
8497
.build()
8598
)
8699
.description("description")
@@ -100,20 +113,31 @@ internal class FileUpdateParamsTest {
100113
),
101114
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
102115
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
103-
.maxTags(5L)
104-
.minConfidence(95L)
116+
.maxTags(10L)
117+
.minConfidence(80L)
105118
.name(
106119
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name
107120
.GOOGLE_AUTO_TAGGING
108121
)
109122
.build()
110123
),
124+
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
125+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
126+
.maxTags(10L)
127+
.minConfidence(80L)
128+
.name(
129+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name
130+
.AWS_AUTO_TAGGING
131+
)
132+
.build()
133+
),
111134
UnnamedSchemaWithArrayParent1.ofAiAutoDescription(),
112135
)
113136
)
114-
.removeAiTagsOfStrings(listOf("string"))
115-
.tags(listOf("car", "vehicle", "motorsports"))
116-
.webhookUrl("https://example.com")
137+
.removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports"))
138+
.addTag("tag1")
139+
.addTag("tag2")
140+
.webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a")
117141
.build()
118142
)
119143
.build()
@@ -124,10 +148,11 @@ internal class FileUpdateParamsTest {
124148
.isEqualTo(
125149
UpdateFileRequest.ofDetails(
126150
UpdateFileRequest.UpdateFileDetails.builder()
127-
.customCoordinates("customCoordinates")
151+
.customCoordinates("10,10,100,100")
128152
.customMetadata(
129153
UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder()
130-
.putAdditionalProperty("foo", JsonValue.from("bar"))
154+
.putAdditionalProperty("brand", JsonValue.from("bar"))
155+
.putAdditionalProperty("color", JsonValue.from("bar"))
131156
.build()
132157
)
133158
.description("description")
@@ -147,20 +172,31 @@ internal class FileUpdateParamsTest {
147172
),
148173
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
149174
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
150-
.maxTags(5L)
151-
.minConfidence(95L)
175+
.maxTags(10L)
176+
.minConfidence(80L)
152177
.name(
153178
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name
154179
.GOOGLE_AUTO_TAGGING
155180
)
156181
.build()
157182
),
183+
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
184+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
185+
.maxTags(10L)
186+
.minConfidence(80L)
187+
.name(
188+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name
189+
.AWS_AUTO_TAGGING
190+
)
191+
.build()
192+
),
158193
UnnamedSchemaWithArrayParent1.ofAiAutoDescription(),
159194
)
160195
)
161-
.removeAiTagsOfStrings(listOf("string"))
162-
.tags(listOf("car", "vehicle", "motorsports"))
163-
.webhookUrl("https://example.com")
196+
.removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports"))
197+
.addTag("tag1")
198+
.addTag("tag2")
199+
.webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a")
164200
.build()
165201
)
166202
)

image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ package com.imagekit.api.models.files
55
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
66
import com.imagekit.api.core.JsonValue
77
import com.imagekit.api.core.jsonMapper
8+
import com.imagekit.api.errors.ImageKitInvalidDataException
89
import com.imagekit.api.models.UnnamedSchemaWithArrayParent1
910
import org.assertj.core.api.Assertions.assertThat
1011
import org.junit.jupiter.api.Test
12+
import org.junit.jupiter.api.assertThrows
13+
import org.junit.jupiter.params.ParameterizedTest
14+
import org.junit.jupiter.params.provider.EnumSource
1115

1216
internal class UpdateFileRequestTest {
1317

@@ -119,7 +123,15 @@ internal class UpdateFileRequestTest {
119123

120124
@Test
121125
fun ofChangePublicationStatus() {
122-
val changePublicationStatus = JsonValue.from(mapOf<String, Any>())
126+
val changePublicationStatus =
127+
UpdateFileRequest.ChangePublicationStatus.builder()
128+
.publish(
129+
UpdateFileRequest.ChangePublicationStatus.Publish.builder()
130+
.isPublished(true)
131+
.includeFileVersions(true)
132+
.build()
133+
)
134+
.build()
123135

124136
val updateFileRequest = UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus)
125137

@@ -131,7 +143,16 @@ internal class UpdateFileRequestTest {
131143
fun ofChangePublicationStatusRoundtrip() {
132144
val jsonMapper = jsonMapper()
133145
val updateFileRequest =
134-
UpdateFileRequest.ofChangePublicationStatus(JsonValue.from(mapOf<String, Any>()))
146+
UpdateFileRequest.ofChangePublicationStatus(
147+
UpdateFileRequest.ChangePublicationStatus.builder()
148+
.publish(
149+
UpdateFileRequest.ChangePublicationStatus.Publish.builder()
150+
.isPublished(true)
151+
.includeFileVersions(true)
152+
.build()
153+
)
154+
.build()
155+
)
135156

136157
val roundtrippedUpdateFileRequest =
137158
jsonMapper.readValue(
@@ -141,4 +162,22 @@ internal class UpdateFileRequestTest {
141162

142163
assertThat(roundtrippedUpdateFileRequest).isEqualTo(updateFileRequest)
143164
}
165+
166+
enum class IncompatibleJsonShapeTestCase(val value: JsonValue) {
167+
BOOLEAN(JsonValue.from(false)),
168+
STRING(JsonValue.from("invalid")),
169+
INTEGER(JsonValue.from(-1)),
170+
FLOAT(JsonValue.from(3.14)),
171+
ARRAY(JsonValue.from(listOf("invalid", "array"))),
172+
}
173+
174+
@ParameterizedTest
175+
@EnumSource
176+
fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) {
177+
val updateFileRequest =
178+
jsonMapper().convertValue(testCase.value, jacksonTypeRef<UpdateFileRequest>())
179+
180+
val e = assertThrows<ImageKitInvalidDataException> { updateFileRequest.validate() }
181+
assertThat(e).hasMessageStartingWith("Unknown ")
182+
}
144183
}

image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ internal class FileServiceAsyncTest {
3636
.fileId("fileId")
3737
.updateFileRequest(
3838
UpdateFileRequest.UpdateFileDetails.builder()
39-
.customCoordinates("customCoordinates")
39+
.customCoordinates("10,10,100,100")
4040
.customMetadata(
4141
UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder()
42-
.putAdditionalProperty("foo", JsonValue.from("bar"))
42+
.putAdditionalProperty("brand", JsonValue.from("bar"))
43+
.putAdditionalProperty("color", JsonValue.from("bar"))
4344
.build()
4445
)
4546
.description("description")
@@ -60,21 +61,33 @@ internal class FileServiceAsyncTest {
6061
),
6162
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
6263
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
63-
.maxTags(5L)
64-
.minConfidence(95L)
64+
.maxTags(10L)
65+
.minConfidence(80L)
6566
.name(
6667
UnnamedSchemaWithArrayParent1.AutoTaggingExtension
6768
.Name
6869
.GOOGLE_AUTO_TAGGING
6970
)
7071
.build()
7172
),
73+
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
74+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
75+
.maxTags(10L)
76+
.minConfidence(80L)
77+
.name(
78+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension
79+
.Name
80+
.AWS_AUTO_TAGGING
81+
)
82+
.build()
83+
),
7284
UnnamedSchemaWithArrayParent1.ofAiAutoDescription(),
7385
)
7486
)
75-
.removeAiTagsOfStrings(listOf("string"))
76-
.tags(listOf("car", "vehicle", "motorsports"))
77-
.webhookUrl("https://example.com")
87+
.removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports"))
88+
.addTag("tag1")
89+
.addTag("tag2")
90+
.webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a")
7891
.build()
7992
)
8093
.build()

image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ internal class FileServiceTest {
3636
.fileId("fileId")
3737
.updateFileRequest(
3838
UpdateFileRequest.UpdateFileDetails.builder()
39-
.customCoordinates("customCoordinates")
39+
.customCoordinates("10,10,100,100")
4040
.customMetadata(
4141
UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder()
42-
.putAdditionalProperty("foo", JsonValue.from("bar"))
42+
.putAdditionalProperty("brand", JsonValue.from("bar"))
43+
.putAdditionalProperty("color", JsonValue.from("bar"))
4344
.build()
4445
)
4546
.description("description")
@@ -60,21 +61,33 @@ internal class FileServiceTest {
6061
),
6162
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
6263
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
63-
.maxTags(5L)
64-
.minConfidence(95L)
64+
.maxTags(10L)
65+
.minConfidence(80L)
6566
.name(
6667
UnnamedSchemaWithArrayParent1.AutoTaggingExtension
6768
.Name
6869
.GOOGLE_AUTO_TAGGING
6970
)
7071
.build()
7172
),
73+
UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(
74+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder()
75+
.maxTags(10L)
76+
.minConfidence(80L)
77+
.name(
78+
UnnamedSchemaWithArrayParent1.AutoTaggingExtension
79+
.Name
80+
.AWS_AUTO_TAGGING
81+
)
82+
.build()
83+
),
7284
UnnamedSchemaWithArrayParent1.ofAiAutoDescription(),
7385
)
7486
)
75-
.removeAiTagsOfStrings(listOf("string"))
76-
.tags(listOf("car", "vehicle", "motorsports"))
77-
.webhookUrl("https://example.com")
87+
.removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports"))
88+
.addTag("tag1")
89+
.addTag("tag2")
90+
.webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a")
7891
.build()
7992
)
8093
.build()

0 commit comments

Comments
 (0)