Skip to content

Commit 79fb06d

Browse files
feat(api): update via SDK Studio (#40)
1 parent 01a6acb commit 79fb06d

File tree

89 files changed

+1706
-2211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1706
-2211
lines changed

.devcontainer/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# syntax=docker/dockerfile:1
22
FROM debian:bookworm-slim
33

4-
RUN apt-get update && apt-get install -y \
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
55
libxkbcommon0 \
66
ca-certificates \
77
ca-certificates-java \
88
make \
99
curl \
1010
git \
11-
openjdk-17-jdk \
11+
openjdk-17-jdk-headless \
1212
unzip \
1313
libc++1 \
1414
vim \

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,17 @@ import com.openlayer.api.models.InferencePipelineDataStreamResponse;
7777
import java.util.List;
7878

7979
InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.builder()
80-
.rows(List.of(InferencePipelineDataStreamParams.Row.builder().build()))
80+
.inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
8181
.config(InferencePipelineDataStreamParams.Config.ofLlmData(InferencePipelineDataStreamParams.Config.LlmData.builder()
8282
.outputColumnName("output")
8383
.costColumnName("cost")
8484
.inputVariableNames(List.of("user_query"))
8585
.numOfTokenColumnName("tokens")
8686
.timestampColumnName("timestamp")
8787
.build()))
88+
.row(List.of(InferencePipelineDataStreamParams.Row.builder().build()))
8889
.build();
89-
InferencePipelineDataStreamResponse inferencePipelineDataStreamResponse = client.inferencePipelines().data().stream(params);
90+
InferencePipelineDataStreamResponse response = client.inferencePipelines().data().stream(params);
9091
```
9192

9293
---
@@ -118,7 +119,7 @@ InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.bui
118119
When receiving a response, the Openlayer Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OpenlayerInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model.
119120

120121
```java
121-
InferencePipelineDataStreamResponse inferencePipelineDataStreamResponse = client.inferencePipelines().data().stream().validate();
122+
InferencePipelineDataStreamResponse response = client.inferencePipelines().data().stream().validate();
122123
```
123124

124125
### Response properties as JSON
@@ -148,7 +149,7 @@ if (field.isMissing()) {
148149
Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method:
149150

150151
```java
151-
JsonValue secret = inferencePipelineDataStreamResponse._additionalProperties().get("secret_field");
152+
JsonValue secret = projectCreateResponse._additionalProperties().get("secret_field");
152153
```
153154

154155
---

buildSrc/src/main/kotlin/openlayer.java.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ configure<SpotlessExtension> {
1919
importOrder()
2020
removeUnusedImports()
2121
palantirJavaFormat()
22+
toggleOffOn()
2223
}
2324
}
2425

buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ kotlin {
1616
configure<SpotlessExtension> {
1717
kotlin {
1818
ktfmt().kotlinlangStyle()
19+
toggleOffOn()
1920
}
2021
}
2122

openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OkHttpClient.kt

+12-32
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
6666
request.body?.run { future.whenComplete { _, _ -> close() } }
6767

6868
val call = getClient(requestOptions).newCall(request.toRequest())
69-
7069
call.enqueue(
7170
object : Callback {
7271
override fun onResponse(call: Call, response: Response) {
@@ -90,7 +89,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
9089

9190
private fun HttpRequest.toRequest(): Request {
9291
var body: RequestBody? = body?.toRequestBody()
93-
// OkHttpClient always requires a request body for PUT and POST methods
92+
// OkHttpClient always requires a request body for PUT and POST methods.
9493
if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) {
9594
body = "".toRequestBody()
9695
}
@@ -118,43 +117,27 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
118117
val length = contentLength()
119118

120119
return object : RequestBody() {
121-
override fun contentType(): MediaType? {
122-
return mediaType
123-
}
120+
override fun contentType(): MediaType? = mediaType
124121

125-
override fun contentLength(): Long {
126-
return length
127-
}
122+
override fun contentLength(): Long = length
128123

129-
override fun isOneShot(): Boolean {
130-
return !repeatable()
131-
}
124+
override fun isOneShot(): Boolean = !repeatable()
132125

133-
override fun writeTo(sink: BufferedSink) {
134-
writeTo(sink.outputStream())
135-
}
126+
override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
136127
}
137128
}
138129

139130
private fun Response.toResponse(): HttpResponse {
140131
val headers = headers.toHeaders()
141132

142133
return object : HttpResponse {
143-
override fun statusCode(): Int {
144-
return code
145-
}
134+
override fun statusCode(): Int = code
146135

147-
override fun headers(): ListMultimap<String, String> {
148-
return headers
149-
}
136+
override fun headers(): ListMultimap<String, String> = headers
150137

151-
override fun body(): InputStream {
152-
return body!!.byteStream()
153-
}
138+
override fun body(): InputStream = body!!.byteStream()
154139

155-
override fun close() {
156-
body!!.close()
157-
}
140+
override fun close() = body!!.close()
158141
}
159142
}
160143

@@ -163,9 +146,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
163146
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
164147
.arrayListValues()
165148
.build<String, String>()
166-
167149
forEach { pair -> headers.put(pair.first, pair.second) }
168-
169150
return headers
170151
}
171152

@@ -176,7 +157,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
176157
class Builder {
177158

178159
private var baseUrl: HttpUrl? = null
179-
// default timeout is 1 minute
160+
// The default timeout is 1 minute.
180161
private var timeout: Duration = Duration.ofSeconds(60)
181162
private var proxy: Proxy? = null
182163

@@ -186,8 +167,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
186167

187168
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
188169

189-
fun build(): OkHttpClient {
190-
return OkHttpClient(
170+
fun build(): OkHttpClient =
171+
OkHttpClient(
191172
okhttp3.OkHttpClient.Builder()
192173
.connectTimeout(timeout)
193174
.readTimeout(timeout)
@@ -197,6 +178,5 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
197178
.build(),
198179
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
199180
)
200-
}
201181
}
202182
}

openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClient.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OpenlayerOkHttpClient private constructor() {
2323

2424
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
2525
private var baseUrl: String = ClientOptions.PRODUCTION_URL
26-
// default timeout for client is 1 minute
26+
// The default timeout for the client is 1 minute.
2727
private var timeout: Duration = Duration.ofSeconds(60)
2828
private var proxy: Proxy? = null
2929

@@ -66,8 +66,8 @@ class OpenlayerOkHttpClient private constructor() {
6666

6767
fun fromEnv() = apply { clientOptions.fromEnv() }
6868

69-
fun build(): OpenlayerClient {
70-
return OpenlayerClientImpl(
69+
fun build(): OpenlayerClient =
70+
OpenlayerClientImpl(
7171
clientOptions
7272
.httpClient(
7373
OkHttpClient.builder()
@@ -78,6 +78,5 @@ class OpenlayerOkHttpClient private constructor() {
7878
)
7979
.build()
8080
)
81-
}
8281
}
8382
}

openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClientAsync.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OpenlayerOkHttpClientAsync private constructor() {
2323

2424
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
2525
private var baseUrl: String = ClientOptions.PRODUCTION_URL
26-
// default timeout for client is 1 minute
26+
// The default timeout for the client is 1 minute.
2727
private var timeout: Duration = Duration.ofSeconds(60)
2828
private var proxy: Proxy? = null
2929

@@ -66,8 +66,8 @@ class OpenlayerOkHttpClientAsync private constructor() {
6666

6767
fun fromEnv() = apply { clientOptions.fromEnv() }
6868

69-
fun build(): OpenlayerClientAsync {
70-
return OpenlayerClientAsyncImpl(
69+
fun build(): OpenlayerClientAsync =
70+
OpenlayerClientAsyncImpl(
7171
clientOptions
7272
.httpClient(
7373
OkHttpClient.builder()
@@ -78,6 +78,5 @@ class OpenlayerOkHttpClientAsync private constructor() {
7878
)
7979
.build()
8080
)
81-
}
8281
}
8382
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// File generated from our OpenAPI spec by Stainless.
22

3-
@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102
4-
53
package com.openlayer.api.client
64

75
import com.openlayer.api.models.*

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// File generated from our OpenAPI spec by Stainless.
22

3-
@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102
4-
53
package com.openlayer.api.client
64

75
import com.openlayer.api.models.*

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

+19-8
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,41 @@
33
package com.openlayer.api.client
44

55
import com.openlayer.api.core.ClientOptions
6-
import com.openlayer.api.core.http.HttpResponse.Handler
7-
import com.openlayer.api.errors.OpenlayerError
6+
import com.openlayer.api.core.getPackageVersion
87
import com.openlayer.api.models.*
98
import com.openlayer.api.services.async.*
10-
import com.openlayer.api.services.errorHandler
119

1210
class OpenlayerClientAsyncImpl
1311
constructor(
1412
private val clientOptions: ClientOptions,
1513
) : OpenlayerClientAsync {
1614

17-
private val errorHandler: Handler<OpenlayerError> = errorHandler(clientOptions.jsonMapper)
15+
private val clientOptionsWithUserAgent =
16+
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
17+
else
18+
clientOptions
19+
.toBuilder()
20+
.putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}")
21+
.build()
1822

23+
// Pass the original clientOptions so that this client sets its own User-Agent.
1924
private val sync: OpenlayerClient by lazy { OpenlayerClientImpl(clientOptions) }
2025

21-
private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) }
26+
private val projects: ProjectServiceAsync by lazy {
27+
ProjectServiceAsyncImpl(clientOptionsWithUserAgent)
28+
}
2229

23-
private val commits: CommitServiceAsync by lazy { CommitServiceAsyncImpl(clientOptions) }
30+
private val commits: CommitServiceAsync by lazy {
31+
CommitServiceAsyncImpl(clientOptionsWithUserAgent)
32+
}
2433

2534
private val inferencePipelines: InferencePipelineServiceAsync by lazy {
26-
InferencePipelineServiceAsyncImpl(clientOptions)
35+
InferencePipelineServiceAsyncImpl(clientOptionsWithUserAgent)
2736
}
2837

29-
private val storage: StorageServiceAsync by lazy { StorageServiceAsyncImpl(clientOptions) }
38+
private val storage: StorageServiceAsync by lazy {
39+
StorageServiceAsyncImpl(clientOptionsWithUserAgent)
40+
}
3041

3142
override fun sync(): OpenlayerClient = sync
3243

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

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@
33
package com.openlayer.api.client
44

55
import com.openlayer.api.core.ClientOptions
6-
import com.openlayer.api.core.http.HttpResponse.Handler
7-
import com.openlayer.api.errors.OpenlayerError
6+
import com.openlayer.api.core.getPackageVersion
87
import com.openlayer.api.models.*
98
import com.openlayer.api.services.blocking.*
10-
import com.openlayer.api.services.errorHandler
119

1210
class OpenlayerClientImpl
1311
constructor(
1412
private val clientOptions: ClientOptions,
1513
) : OpenlayerClient {
1614

17-
private val errorHandler: Handler<OpenlayerError> = errorHandler(clientOptions.jsonMapper)
15+
private val clientOptionsWithUserAgent =
16+
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
17+
else
18+
clientOptions
19+
.toBuilder()
20+
.putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}")
21+
.build()
1822

23+
// Pass the original clientOptions so that this client sets its own User-Agent.
1924
private val async: OpenlayerClientAsync by lazy { OpenlayerClientAsyncImpl(clientOptions) }
2025

21-
private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptions) }
26+
private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) }
2227

23-
private val commits: CommitService by lazy { CommitServiceImpl(clientOptions) }
28+
private val commits: CommitService by lazy { CommitServiceImpl(clientOptionsWithUserAgent) }
2429

2530
private val inferencePipelines: InferencePipelineService by lazy {
26-
InferencePipelineServiceImpl(clientOptions)
31+
InferencePipelineServiceImpl(clientOptionsWithUserAgent)
2732
}
2833

29-
private val storage: StorageService by lazy { StorageServiceImpl(clientOptions) }
34+
private val storage: StorageService by lazy { StorageServiceImpl(clientOptionsWithUserAgent) }
3035

3136
override fun async(): OpenlayerClientAsync = async
3237

0 commit comments

Comments
 (0)