2
2
3
3
package com.openlayer.api.models
4
4
5
+ import com.fasterxml.jackson.annotation.JsonCreator
6
+ import com.openlayer.api.core.Enum
7
+ import com.openlayer.api.core.JsonField
5
8
import com.openlayer.api.core.NoAutoDetect
6
9
import com.openlayer.api.core.http.Headers
7
10
import com.openlayer.api.core.http.QueryParams
11
+ import com.openlayer.api.core.toImmutable
12
+ import com.openlayer.api.errors.OpenlayerInvalidDataException
8
13
import java.util.Objects
14
+ import java.util.Optional
9
15
10
16
class InferencePipelineRetrieveParams
11
17
constructor (
12
18
private val inferencePipelineId: String ,
19
+ private val expand: List <Expand >? ,
13
20
private val additionalHeaders: Headers ,
14
21
private val additionalQueryParams: QueryParams ,
15
22
) {
16
23
17
24
fun inferencePipelineId (): String = inferencePipelineId
18
25
26
+ fun expand (): Optional <List <Expand >> = Optional .ofNullable(expand)
27
+
19
28
fun _additionalHeaders (): Headers = additionalHeaders
20
29
21
30
fun _additionalQueryParams (): QueryParams = additionalQueryParams
22
31
23
32
@JvmSynthetic internal fun getHeaders (): Headers = additionalHeaders
24
33
25
- @JvmSynthetic internal fun getQueryParams (): QueryParams = additionalQueryParams
34
+ @JvmSynthetic
35
+ internal fun getQueryParams (): QueryParams {
36
+ val queryParams = QueryParams .builder()
37
+ this .expand?.let { queryParams.put(" expand" , listOf (it.joinToString(separator = " ," ))) }
38
+ queryParams.putAll(additionalQueryParams)
39
+ return queryParams.build()
40
+ }
26
41
27
42
fun getPathParam (index : Int ): String {
28
43
return when (index) {
@@ -42,13 +57,15 @@ constructor(
42
57
class Builder {
43
58
44
59
private var inferencePipelineId: String? = null
60
+ private var expand: MutableList <Expand > = mutableListOf ()
45
61
private var additionalHeaders: Headers .Builder = Headers .builder()
46
62
private var additionalQueryParams: QueryParams .Builder = QueryParams .builder()
47
63
48
64
@JvmSynthetic
49
65
internal fun from (inferencePipelineRetrieveParams : InferencePipelineRetrieveParams ) =
50
66
apply {
51
67
inferencePipelineId = inferencePipelineRetrieveParams.inferencePipelineId
68
+ expand = inferencePipelineRetrieveParams.expand?.toMutableList() ? : mutableListOf ()
52
69
additionalHeaders = inferencePipelineRetrieveParams.additionalHeaders.toBuilder()
53
70
additionalQueryParams =
54
71
inferencePipelineRetrieveParams.additionalQueryParams.toBuilder()
@@ -58,6 +75,15 @@ constructor(
58
75
this .inferencePipelineId = inferencePipelineId
59
76
}
60
77
78
+ /* * Expand specific nested objects. */
79
+ fun expand (expand : List <Expand >) = apply {
80
+ this .expand.clear()
81
+ this .expand.addAll(expand)
82
+ }
83
+
84
+ /* * Expand specific nested objects. */
85
+ fun addExpand (expand : Expand ) = apply { this .expand.add(expand) }
86
+
61
87
fun additionalHeaders (additionalHeaders : Headers ) = apply {
62
88
this .additionalHeaders.clear()
63
89
putAllAdditionalHeaders(additionalHeaders)
@@ -161,21 +187,79 @@ constructor(
161
187
checkNotNull(inferencePipelineId) {
162
188
" `inferencePipelineId` is required but was not set"
163
189
},
190
+ expand.toImmutable().ifEmpty { null },
164
191
additionalHeaders.build(),
165
192
additionalQueryParams.build(),
166
193
)
167
194
}
168
195
196
+ class Expand
197
+ @JsonCreator
198
+ private constructor (
199
+ private val value: JsonField <String >,
200
+ ) : Enum {
201
+
202
+ @com.fasterxml.jackson.annotation.JsonValue fun _value (): JsonField <String > = value
203
+
204
+ companion object {
205
+
206
+ @JvmField val PROJECT = of(" project" )
207
+
208
+ @JvmField val WORKSPACE = of(" workspace" )
209
+
210
+ @JvmStatic fun of (value : String ) = Expand (JsonField .of(value))
211
+ }
212
+
213
+ enum class Known {
214
+ PROJECT ,
215
+ WORKSPACE ,
216
+ }
217
+
218
+ enum class Value {
219
+ PROJECT ,
220
+ WORKSPACE ,
221
+ _UNKNOWN ,
222
+ }
223
+
224
+ fun value (): Value =
225
+ when (this ) {
226
+ PROJECT -> Value .PROJECT
227
+ WORKSPACE -> Value .WORKSPACE
228
+ else -> Value ._UNKNOWN
229
+ }
230
+
231
+ fun known (): Known =
232
+ when (this ) {
233
+ PROJECT -> Known .PROJECT
234
+ WORKSPACE -> Known .WORKSPACE
235
+ else -> throw OpenlayerInvalidDataException (" Unknown Expand: $value " )
236
+ }
237
+
238
+ fun asString (): String = _value ().asStringOrThrow()
239
+
240
+ override fun equals (other : Any? ): Boolean {
241
+ if (this == = other) {
242
+ return true
243
+ }
244
+
245
+ return /* spotless:off */ other is Expand && value == other.value /* spotless:on */
246
+ }
247
+
248
+ override fun hashCode () = value.hashCode()
249
+
250
+ override fun toString () = value.toString()
251
+ }
252
+
169
253
override fun equals (other : Any? ): Boolean {
170
254
if (this == = other) {
171
255
return true
172
256
}
173
257
174
- return /* spotless:off */ other is InferencePipelineRetrieveParams && inferencePipelineId == other.inferencePipelineId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
258
+ return /* spotless:off */ other is InferencePipelineRetrieveParams && inferencePipelineId == other.inferencePipelineId && expand == other.expand && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
175
259
}
176
260
177
- override fun hashCode (): Int = /* spotless:off */ Objects .hash(inferencePipelineId, additionalHeaders, additionalQueryParams) /* spotless:on */
261
+ override fun hashCode (): Int = /* spotless:off */ Objects .hash(inferencePipelineId, expand, additionalHeaders, additionalQueryParams) /* spotless:on */
178
262
179
263
override fun toString () =
180
- " InferencePipelineRetrieveParams{inferencePipelineId=$inferencePipelineId , additionalHeaders=$additionalHeaders , additionalQueryParams=$additionalQueryParams }"
264
+ " InferencePipelineRetrieveParams{inferencePipelineId=$inferencePipelineId , expand= $expand , additionalHeaders=$additionalHeaders , additionalQueryParams=$additionalQueryParams }"
181
265
}
0 commit comments