Skip to content

Commit aa6fca3

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore: rebuild project due to codegen change (#3)
1 parent 3df1f83 commit aa6fca3

35 files changed

+1018
-260
lines changed

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

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
8080

8181
private fun HttpRequest.toRequest(): Request {
8282
var body: RequestBody? = body?.toRequestBody()
83-
// OkHttpClient always requires a request body for PUT and POST methods
83+
// OkHttpClient always requires a request body for PUT and POST methods.
8484
if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) {
8585
body = "".toRequestBody()
8686
}
@@ -108,43 +108,27 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
108108
val length = contentLength()
109109

110110
return object : RequestBody() {
111-
override fun contentType(): MediaType? {
112-
return mediaType
113-
}
111+
override fun contentType(): MediaType? = mediaType
114112

115-
override fun contentLength(): Long {
116-
return length
117-
}
113+
override fun contentLength(): Long = length
118114

119-
override fun isOneShot(): Boolean {
120-
return !repeatable()
121-
}
115+
override fun isOneShot(): Boolean = !repeatable()
122116

123-
override fun writeTo(sink: BufferedSink) {
124-
writeTo(sink.outputStream())
125-
}
117+
override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
126118
}
127119
}
128120

129121
private fun Response.toResponse(): HttpResponse {
130122
val headers = headers.toHeaders()
131123

132124
return object : HttpResponse {
133-
override fun statusCode(): Int {
134-
return code
135-
}
125+
override fun statusCode(): Int = code
136126

137-
override fun headers(): ListMultimap<String, String> {
138-
return headers
139-
}
127+
override fun headers(): ListMultimap<String, String> = headers
140128

141-
override fun body(): InputStream {
142-
return body!!.byteStream()
143-
}
129+
override fun body(): InputStream = body!!.byteStream()
144130

145-
override fun close() {
146-
body!!.close()
147-
}
131+
override fun close() = body!!.close()
148132
}
149133
}
150134

@@ -153,9 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
153137
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
154138
.arrayListValues()
155139
.build<String, String>()
156-
157140
forEach { pair -> headers.put(pair.first, pair.second) }
158-
159141
return headers
160142
}
161143

@@ -166,7 +148,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
166148
class Builder {
167149

168150
private var baseUrl: HttpUrl? = null
169-
// default timeout is 1 minute
151+
// The default timeout is 1 minute.
170152
private var timeout: Duration = Duration.ofSeconds(60)
171153
private var proxy: Proxy? = null
172154

@@ -176,8 +158,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
176158

177159
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
178160

179-
fun build(): OkHttpClient {
180-
return OkHttpClient(
161+
fun build(): OkHttpClient =
162+
OkHttpClient(
181163
okhttp3.OkHttpClient.Builder()
182164
.connectTimeout(timeout)
183165
.readTimeout(timeout)
@@ -187,7 +169,6 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
187169
.build(),
188170
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
189171
)
190-
}
191172
}
192173

193174
private suspend fun Call.executeAsync(): Response =

omnistack-kotlin-client-okhttp/src/main/kotlin/com/omnistack/api/client/okhttp/OmnistackOkHttpClient.kt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OmnistackOkHttpClient 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

@@ -52,6 +52,24 @@ class OmnistackOkHttpClient private constructor() {
5252

5353
fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) }
5454

55+
fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
56+
clientOptions.queryParams(queryParams)
57+
}
58+
59+
fun putQueryParam(key: String, value: String) = apply {
60+
clientOptions.putQueryParam(key, value)
61+
}
62+
63+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
64+
clientOptions.putQueryParams(key, values)
65+
}
66+
67+
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
68+
clientOptions.putAllQueryParams(queryParams)
69+
}
70+
71+
fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) }
72+
5573
fun timeout(timeout: Duration) = apply { this.timeout = timeout }
5674

5775
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
@@ -66,8 +84,8 @@ class OmnistackOkHttpClient private constructor() {
6684

6785
fun fromEnv() = apply { clientOptions.fromEnv() }
6886

69-
fun build(): OmnistackClient {
70-
return OmnistackClientImpl(
87+
fun build(): OmnistackClient =
88+
OmnistackClientImpl(
7189
clientOptions
7290
.httpClient(
7391
OkHttpClient.builder()
@@ -78,6 +96,5 @@ class OmnistackOkHttpClient private constructor() {
7896
)
7997
.build()
8098
)
81-
}
8299
}
83100
}

omnistack-kotlin-client-okhttp/src/main/kotlin/com/omnistack/api/client/okhttp/OmnistackOkHttpClientAsync.kt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OmnistackOkHttpClientAsync 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

@@ -52,6 +52,24 @@ class OmnistackOkHttpClientAsync private constructor() {
5252

5353
fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) }
5454

55+
fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
56+
clientOptions.queryParams(queryParams)
57+
}
58+
59+
fun putQueryParam(key: String, value: String) = apply {
60+
clientOptions.putQueryParam(key, value)
61+
}
62+
63+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
64+
clientOptions.putQueryParams(key, values)
65+
}
66+
67+
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
68+
clientOptions.putAllQueryParams(queryParams)
69+
}
70+
71+
fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) }
72+
5573
fun timeout(timeout: Duration) = apply { this.timeout = timeout }
5674

5775
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
@@ -66,8 +84,8 @@ class OmnistackOkHttpClientAsync private constructor() {
6684

6785
fun fromEnv() = apply { clientOptions.fromEnv() }
6886

69-
fun build(): OmnistackClientAsync {
70-
return OmnistackClientAsyncImpl(
87+
fun build(): OmnistackClientAsync =
88+
OmnistackClientAsyncImpl(
7189
clientOptions
7290
.httpClient(
7391
OkHttpClient.builder()
@@ -78,6 +96,5 @@ class OmnistackOkHttpClientAsync private constructor() {
7896
)
7997
.build()
8098
)
81-
}
8299
}
83100
}

omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/client/OmnistackClient.kt

Lines changed: 0 additions & 2 deletions
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.omnistack.api.client
64

75
import com.omnistack.api.models.*

omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/client/OmnistackClientAsync.kt

Lines changed: 0 additions & 2 deletions
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.omnistack.api.client
64

75
import com.omnistack.api.models.*

omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/client/OmnistackClientAsyncImpl.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.omnistack.api.client
44

55
import com.omnistack.api.core.ClientOptions
6+
import com.omnistack.api.core.getPackageVersion
67
import com.omnistack.api.models.*
78
import com.omnistack.api.services.async.*
89

@@ -11,12 +12,21 @@ constructor(
1112
private val clientOptions: ClientOptions,
1213
) : OmnistackClientAsync {
1314

15+
private val clientOptionsWithUserAgent =
16+
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
17+
else
18+
clientOptions
19+
.toBuilder()
20+
.putHeader("User-Agent", "${javaClass.simpleName}/Kotlin ${getPackageVersion()}")
21+
.build()
22+
23+
// Pass the original clientOptions so that this client sets its own User-Agent.
1424
private val sync: OmnistackClient by lazy { OmnistackClientImpl(clientOptions) }
1525

16-
private val chats: ChatServiceAsync by lazy { ChatServiceAsyncImpl(clientOptions) }
26+
private val chats: ChatServiceAsync by lazy { ChatServiceAsyncImpl(clientOptionsWithUserAgent) }
1727

1828
private val completions: CompletionServiceAsync by lazy {
19-
CompletionServiceAsyncImpl(clientOptions)
29+
CompletionServiceAsyncImpl(clientOptionsWithUserAgent)
2030
}
2131

2232
override fun sync(): OmnistackClient = sync

omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/client/OmnistackClientImpl.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.omnistack.api.client
44

55
import com.omnistack.api.core.ClientOptions
6+
import com.omnistack.api.core.getPackageVersion
67
import com.omnistack.api.models.*
78
import com.omnistack.api.services.blocking.*
89

@@ -11,11 +12,22 @@ constructor(
1112
private val clientOptions: ClientOptions,
1213
) : OmnistackClient {
1314

15+
private val clientOptionsWithUserAgent =
16+
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
17+
else
18+
clientOptions
19+
.toBuilder()
20+
.putHeader("User-Agent", "${javaClass.simpleName}/Kotlin ${getPackageVersion()}")
21+
.build()
22+
23+
// Pass the original clientOptions so that this client sets its own User-Agent.
1424
private val async: OmnistackClientAsync by lazy { OmnistackClientAsyncImpl(clientOptions) }
1525

16-
private val chats: ChatService by lazy { ChatServiceImpl(clientOptions) }
26+
private val chats: ChatService by lazy { ChatServiceImpl(clientOptionsWithUserAgent) }
1727

18-
private val completions: CompletionService by lazy { CompletionServiceImpl(clientOptions) }
28+
private val completions: CompletionService by lazy {
29+
CompletionServiceImpl(clientOptionsWithUserAgent)
30+
}
1931

2032
override fun async(): OmnistackClientAsync = async
2133

0 commit comments

Comments
 (0)