Skip to content

Commit 83ed19b

Browse files
chore(internal): codegen related update (#18)
1 parent b130be7 commit 83ed19b

19 files changed

+634
-1
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 9
1+
configured_endpoints: 10

openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt

+2
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ interface OpenlayerClient {
1616
fun commits(): CommitService
1717

1818
fun inferencePipelines(): InferencePipelineService
19+
20+
fun storage(): StorageService
1921
}

openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt

+2
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ interface OpenlayerClientAsync {
1616
fun commits(): CommitServiceAsync
1717

1818
fun inferencePipelines(): InferencePipelineServiceAsync
19+
20+
fun storage(): StorageServiceAsync
1921
}

openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt

+4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ constructor(
2626
InferencePipelineServiceAsyncImpl(clientOptions)
2727
}
2828

29+
private val storage: StorageServiceAsync by lazy { StorageServiceAsyncImpl(clientOptions) }
30+
2931
override fun sync(): OpenlayerClient = sync
3032

3133
override fun projects(): ProjectServiceAsync = projects
3234

3335
override fun commits(): CommitServiceAsync = commits
3436

3537
override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines
38+
39+
override fun storage(): StorageServiceAsync = storage
3640
}

openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt

+4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ constructor(
2626
InferencePipelineServiceImpl(clientOptions)
2727
}
2828

29+
private val storage: StorageService by lazy { StorageServiceImpl(clientOptions) }
30+
2931
override fun async(): OpenlayerClientAsync = async
3032

3133
override fun projects(): ProjectService = projects
3234

3335
override fun commits(): CommitService = commits
3436

3537
override fun inferencePipelines(): InferencePipelineService = inferencePipelines
38+
39+
override fun storage(): StorageService = storage
3640
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.openlayer.api.models
4+
5+
import com.openlayer.api.core.JsonValue
6+
import com.openlayer.api.core.NoAutoDetect
7+
import com.openlayer.api.core.toUnmodifiable
8+
import com.openlayer.api.models.*
9+
import java.util.Objects
10+
import java.util.Optional
11+
12+
class StoragePresignedUrlCreateParams
13+
constructor(
14+
private val objectName: String,
15+
private val additionalQueryParams: Map<String, List<String>>,
16+
private val additionalHeaders: Map<String, List<String>>,
17+
private val additionalBodyProperties: Map<String, JsonValue>,
18+
) {
19+
20+
fun objectName(): String = objectName
21+
22+
@JvmSynthetic
23+
internal fun getBody(): Optional<Map<String, JsonValue>> {
24+
return Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
25+
}
26+
27+
@JvmSynthetic
28+
internal fun getQueryParams(): Map<String, List<String>> {
29+
val params = mutableMapOf<String, List<String>>()
30+
this.objectName.let { params.put("objectName", listOf(it.toString())) }
31+
params.putAll(additionalQueryParams)
32+
return params.toUnmodifiable()
33+
}
34+
35+
@JvmSynthetic internal fun getHeaders(): Map<String, List<String>> = additionalHeaders
36+
37+
fun _additionalQueryParams(): Map<String, List<String>> = additionalQueryParams
38+
39+
fun _additionalHeaders(): Map<String, List<String>> = additionalHeaders
40+
41+
fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties
42+
43+
override fun equals(other: Any?): Boolean {
44+
if (this === other) {
45+
return true
46+
}
47+
48+
return other is StoragePresignedUrlCreateParams &&
49+
this.objectName == other.objectName &&
50+
this.additionalQueryParams == other.additionalQueryParams &&
51+
this.additionalHeaders == other.additionalHeaders &&
52+
this.additionalBodyProperties == other.additionalBodyProperties
53+
}
54+
55+
override fun hashCode(): Int {
56+
return Objects.hash(
57+
objectName,
58+
additionalQueryParams,
59+
additionalHeaders,
60+
additionalBodyProperties,
61+
)
62+
}
63+
64+
override fun toString() =
65+
"StoragePresignedUrlCreateParams{objectName=$objectName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"
66+
67+
fun toBuilder() = Builder().from(this)
68+
69+
companion object {
70+
71+
@JvmStatic fun builder() = Builder()
72+
}
73+
74+
@NoAutoDetect
75+
class Builder {
76+
77+
private var objectName: String? = null
78+
private var additionalQueryParams: MutableMap<String, MutableList<String>> = mutableMapOf()
79+
private var additionalHeaders: MutableMap<String, MutableList<String>> = mutableMapOf()
80+
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()
81+
82+
@JvmSynthetic
83+
internal fun from(storagePresignedUrlCreateParams: StoragePresignedUrlCreateParams) =
84+
apply {
85+
this.objectName = storagePresignedUrlCreateParams.objectName
86+
additionalQueryParams(storagePresignedUrlCreateParams.additionalQueryParams)
87+
additionalHeaders(storagePresignedUrlCreateParams.additionalHeaders)
88+
additionalBodyProperties(storagePresignedUrlCreateParams.additionalBodyProperties)
89+
}
90+
91+
/** The name of the object. */
92+
fun objectName(objectName: String) = apply { this.objectName = objectName }
93+
94+
fun additionalQueryParams(additionalQueryParams: Map<String, List<String>>) = apply {
95+
this.additionalQueryParams.clear()
96+
putAllQueryParams(additionalQueryParams)
97+
}
98+
99+
fun putQueryParam(name: String, value: String) = apply {
100+
this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value)
101+
}
102+
103+
fun putQueryParams(name: String, values: Iterable<String>) = apply {
104+
this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values)
105+
}
106+
107+
fun putAllQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply {
108+
additionalQueryParams.forEach(this::putQueryParams)
109+
}
110+
111+
fun removeQueryParam(name: String) = apply {
112+
this.additionalQueryParams.put(name, mutableListOf())
113+
}
114+
115+
fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
116+
this.additionalHeaders.clear()
117+
putAllHeaders(additionalHeaders)
118+
}
119+
120+
fun putHeader(name: String, value: String) = apply {
121+
this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value)
122+
}
123+
124+
fun putHeaders(name: String, values: Iterable<String>) = apply {
125+
this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values)
126+
}
127+
128+
fun putAllHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
129+
additionalHeaders.forEach(this::putHeaders)
130+
}
131+
132+
fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) }
133+
134+
fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply {
135+
this.additionalBodyProperties.clear()
136+
this.additionalBodyProperties.putAll(additionalBodyProperties)
137+
}
138+
139+
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
140+
this.additionalBodyProperties.put(key, value)
141+
}
142+
143+
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) =
144+
apply {
145+
this.additionalBodyProperties.putAll(additionalBodyProperties)
146+
}
147+
148+
fun build(): StoragePresignedUrlCreateParams =
149+
StoragePresignedUrlCreateParams(
150+
checkNotNull(objectName) { "`objectName` is required but was not set" },
151+
additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
152+
additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
153+
additionalBodyProperties.toUnmodifiable(),
154+
)
155+
}
156+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.openlayer.api.models
4+
5+
import com.fasterxml.jackson.annotation.JsonAnyGetter
6+
import com.fasterxml.jackson.annotation.JsonAnySetter
7+
import com.fasterxml.jackson.annotation.JsonProperty
8+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
9+
import com.openlayer.api.core.ExcludeMissing
10+
import com.openlayer.api.core.JsonField
11+
import com.openlayer.api.core.JsonMissing
12+
import com.openlayer.api.core.JsonValue
13+
import com.openlayer.api.core.NoAutoDetect
14+
import com.openlayer.api.core.toUnmodifiable
15+
import java.util.Objects
16+
17+
@JsonDeserialize(builder = StoragePresignedUrlCreateResponse.Builder::class)
18+
@NoAutoDetect
19+
class StoragePresignedUrlCreateResponse
20+
private constructor(
21+
private val url: JsonField<String>,
22+
private val fields: JsonValue,
23+
private val storageUri: JsonField<String>,
24+
private val additionalProperties: Map<String, JsonValue>,
25+
) {
26+
27+
private var validated: Boolean = false
28+
29+
private var hashCode: Int = 0
30+
31+
/** The presigned url. */
32+
fun url(): String = url.getRequired("url")
33+
34+
/** The storage URI to send back to the backend after the upload was completed. */
35+
fun storageUri(): String = storageUri.getRequired("storageUri")
36+
37+
/** The presigned url. */
38+
@JsonProperty("url") @ExcludeMissing fun _url() = url
39+
40+
/** Fields to include in the body of the upload. Only needed by s3. */
41+
@JsonProperty("fields") @ExcludeMissing fun _fields() = fields
42+
43+
/** The storage URI to send back to the backend after the upload was completed. */
44+
@JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri
45+
46+
@JsonAnyGetter
47+
@ExcludeMissing
48+
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
49+
50+
fun validate(): StoragePresignedUrlCreateResponse = apply {
51+
if (!validated) {
52+
url()
53+
storageUri()
54+
validated = true
55+
}
56+
}
57+
58+
fun toBuilder() = Builder().from(this)
59+
60+
override fun equals(other: Any?): Boolean {
61+
if (this === other) {
62+
return true
63+
}
64+
65+
return other is StoragePresignedUrlCreateResponse &&
66+
this.url == other.url &&
67+
this.fields == other.fields &&
68+
this.storageUri == other.storageUri &&
69+
this.additionalProperties == other.additionalProperties
70+
}
71+
72+
override fun hashCode(): Int {
73+
if (hashCode == 0) {
74+
hashCode =
75+
Objects.hash(
76+
url,
77+
fields,
78+
storageUri,
79+
additionalProperties,
80+
)
81+
}
82+
return hashCode
83+
}
84+
85+
override fun toString() =
86+
"StoragePresignedUrlCreateResponse{url=$url, fields=$fields, storageUri=$storageUri, additionalProperties=$additionalProperties}"
87+
88+
companion object {
89+
90+
@JvmStatic fun builder() = Builder()
91+
}
92+
93+
class Builder {
94+
95+
private var url: JsonField<String> = JsonMissing.of()
96+
private var fields: JsonValue = JsonMissing.of()
97+
private var storageUri: JsonField<String> = JsonMissing.of()
98+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
99+
100+
@JvmSynthetic
101+
internal fun from(storagePresignedUrlCreateResponse: StoragePresignedUrlCreateResponse) =
102+
apply {
103+
this.url = storagePresignedUrlCreateResponse.url
104+
this.fields = storagePresignedUrlCreateResponse.fields
105+
this.storageUri = storagePresignedUrlCreateResponse.storageUri
106+
additionalProperties(storagePresignedUrlCreateResponse.additionalProperties)
107+
}
108+
109+
/** The presigned url. */
110+
fun url(url: String) = url(JsonField.of(url))
111+
112+
/** The presigned url. */
113+
@JsonProperty("url")
114+
@ExcludeMissing
115+
fun url(url: JsonField<String>) = apply { this.url = url }
116+
117+
/** Fields to include in the body of the upload. Only needed by s3. */
118+
@JsonProperty("fields")
119+
@ExcludeMissing
120+
fun fields(fields: JsonValue) = apply { this.fields = fields }
121+
122+
/** The storage URI to send back to the backend after the upload was completed. */
123+
fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri))
124+
125+
/** The storage URI to send back to the backend after the upload was completed. */
126+
@JsonProperty("storageUri")
127+
@ExcludeMissing
128+
fun storageUri(storageUri: JsonField<String>) = apply { this.storageUri = storageUri }
129+
130+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
131+
this.additionalProperties.clear()
132+
this.additionalProperties.putAll(additionalProperties)
133+
}
134+
135+
@JsonAnySetter
136+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
137+
this.additionalProperties.put(key, value)
138+
}
139+
140+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
141+
this.additionalProperties.putAll(additionalProperties)
142+
}
143+
144+
fun build(): StoragePresignedUrlCreateResponse =
145+
StoragePresignedUrlCreateResponse(
146+
url,
147+
fields,
148+
storageUri,
149+
additionalProperties.toUnmodifiable(),
150+
)
151+
}
152+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102
4+
5+
package com.openlayer.api.services.async
6+
7+
import com.openlayer.api.services.async.storage.PresignedUrlServiceAsync
8+
9+
interface StorageServiceAsync {
10+
11+
fun presignedUrl(): PresignedUrlServiceAsync
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.openlayer.api.services.async
4+
5+
import com.openlayer.api.core.ClientOptions
6+
import com.openlayer.api.core.http.HttpResponse.Handler
7+
import com.openlayer.api.errors.OpenlayerError
8+
import com.openlayer.api.services.async.storage.PresignedUrlServiceAsync
9+
import com.openlayer.api.services.async.storage.PresignedUrlServiceAsyncImpl
10+
import com.openlayer.api.services.errorHandler
11+
12+
class StorageServiceAsyncImpl
13+
constructor(
14+
private val clientOptions: ClientOptions,
15+
) : StorageServiceAsync {
16+
17+
private val errorHandler: Handler<OpenlayerError> = errorHandler(clientOptions.jsonMapper)
18+
19+
private val presignedUrl: PresignedUrlServiceAsync by lazy {
20+
PresignedUrlServiceAsyncImpl(clientOptions)
21+
}
22+
23+
override fun presignedUrl(): PresignedUrlServiceAsync = presignedUrl
24+
}

0 commit comments

Comments
 (0)