Skip to content

Commit cbbd424

Browse files
feat(api): manual updates
1 parent 4ab06b0 commit cbbd424

21 files changed

+886
-281
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml
33
openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a
4-
config_hash: 4e73c7e12a531edcd1366dab7eccc360
4+
config_hash: 08e12746cdca1c59c897cf2e50893c3c
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.imagekit.api.models.webhooks
4+
5+
import com.fasterxml.jackson.annotation.JsonAnyGetter
6+
import com.fasterxml.jackson.annotation.JsonAnySetter
7+
import com.fasterxml.jackson.annotation.JsonCreator
8+
import com.fasterxml.jackson.annotation.JsonProperty
9+
import com.imagekit.api.core.ExcludeMissing
10+
import com.imagekit.api.core.JsonField
11+
import com.imagekit.api.core.JsonMissing
12+
import com.imagekit.api.core.JsonValue
13+
import com.imagekit.api.core.checkRequired
14+
import com.imagekit.api.errors.ImageKitInvalidDataException
15+
import java.util.Collections
16+
import java.util.Objects
17+
18+
class BaseWebhookEvent
19+
private constructor(
20+
private val id: JsonField<String>,
21+
private val type: JsonField<String>,
22+
private val additionalProperties: MutableMap<String, JsonValue>,
23+
) {
24+
25+
@JsonCreator
26+
private constructor(
27+
@JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(),
28+
@JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(),
29+
) : this(id, type, mutableMapOf())
30+
31+
/**
32+
* Unique identifier for the event.
33+
*
34+
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
35+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
36+
*/
37+
fun id(): String = id.getRequired("id")
38+
39+
/**
40+
* The type of webhook event.
41+
*
42+
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
43+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
44+
*/
45+
fun type(): String = type.getRequired("type")
46+
47+
/**
48+
* Returns the raw JSON value of [id].
49+
*
50+
* Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
51+
*/
52+
@JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id
53+
54+
/**
55+
* Returns the raw JSON value of [type].
56+
*
57+
* Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
58+
*/
59+
@JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type
60+
61+
@JsonAnySetter
62+
private fun putAdditionalProperty(key: String, value: JsonValue) {
63+
additionalProperties.put(key, value)
64+
}
65+
66+
@JsonAnyGetter
67+
@ExcludeMissing
68+
fun _additionalProperties(): Map<String, JsonValue> =
69+
Collections.unmodifiableMap(additionalProperties)
70+
71+
fun toBuilder() = Builder().from(this)
72+
73+
companion object {
74+
75+
/**
76+
* Returns a mutable builder for constructing an instance of [BaseWebhookEvent].
77+
*
78+
* The following fields are required:
79+
* ```java
80+
* .id()
81+
* .type()
82+
* ```
83+
*/
84+
@JvmStatic fun builder() = Builder()
85+
}
86+
87+
/** A builder for [BaseWebhookEvent]. */
88+
class Builder internal constructor() {
89+
90+
private var id: JsonField<String>? = null
91+
private var type: JsonField<String>? = null
92+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
93+
94+
@JvmSynthetic
95+
internal fun from(baseWebhookEvent: BaseWebhookEvent) = apply {
96+
id = baseWebhookEvent.id
97+
type = baseWebhookEvent.type
98+
additionalProperties = baseWebhookEvent.additionalProperties.toMutableMap()
99+
}
100+
101+
/** Unique identifier for the event. */
102+
fun id(id: String) = id(JsonField.of(id))
103+
104+
/**
105+
* Sets [Builder.id] to an arbitrary JSON value.
106+
*
107+
* You should usually call [Builder.id] with a well-typed [String] value instead. This
108+
* method is primarily for setting the field to an undocumented or not yet supported value.
109+
*/
110+
fun id(id: JsonField<String>) = apply { this.id = id }
111+
112+
/** The type of webhook event. */
113+
fun type(type: String) = type(JsonField.of(type))
114+
115+
/**
116+
* Sets [Builder.type] to an arbitrary JSON value.
117+
*
118+
* You should usually call [Builder.type] with a well-typed [String] value instead. This
119+
* method is primarily for setting the field to an undocumented or not yet supported value.
120+
*/
121+
fun type(type: JsonField<String>) = apply { this.type = type }
122+
123+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
124+
this.additionalProperties.clear()
125+
putAllAdditionalProperties(additionalProperties)
126+
}
127+
128+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
129+
additionalProperties.put(key, value)
130+
}
131+
132+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
133+
this.additionalProperties.putAll(additionalProperties)
134+
}
135+
136+
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
137+
138+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
139+
keys.forEach(::removeAdditionalProperty)
140+
}
141+
142+
/**
143+
* Returns an immutable instance of [BaseWebhookEvent].
144+
*
145+
* Further updates to this [Builder] will not mutate the returned instance.
146+
*
147+
* The following fields are required:
148+
* ```java
149+
* .id()
150+
* .type()
151+
* ```
152+
*
153+
* @throws IllegalStateException if any required field is unset.
154+
*/
155+
fun build(): BaseWebhookEvent =
156+
BaseWebhookEvent(
157+
checkRequired("id", id),
158+
checkRequired("type", type),
159+
additionalProperties.toMutableMap(),
160+
)
161+
}
162+
163+
private var validated: Boolean = false
164+
165+
fun validate(): BaseWebhookEvent = apply {
166+
if (validated) {
167+
return@apply
168+
}
169+
170+
id()
171+
type()
172+
validated = true
173+
}
174+
175+
fun isValid(): Boolean =
176+
try {
177+
validate()
178+
true
179+
} catch (e: ImageKitInvalidDataException) {
180+
false
181+
}
182+
183+
/**
184+
* Returns a score indicating how many valid values are contained in this object recursively.
185+
*
186+
* Used for best match union deserialization.
187+
*/
188+
@JvmSynthetic
189+
internal fun validity(): Int =
190+
(if (id.asKnown().isPresent) 1 else 0) + (if (type.asKnown().isPresent) 1 else 0)
191+
192+
override fun equals(other: Any?): Boolean {
193+
if (this === other) {
194+
return true
195+
}
196+
197+
return other is BaseWebhookEvent &&
198+
id == other.id &&
199+
type == other.type &&
200+
additionalProperties == other.additionalProperties
201+
}
202+
203+
private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) }
204+
205+
override fun hashCode(): Int = hashCode
206+
207+
override fun toString() =
208+
"BaseWebhookEvent{id=$id, type=$type, additionalProperties=$additionalProperties}"
209+
}

0 commit comments

Comments
 (0)