Skip to content

Commit

Permalink
chore: rebuild project due to codegen change (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 4, 2024
1 parent 3df1f83 commit aa6fca3
Show file tree
Hide file tree
Showing 35 changed files with 1,018 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

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

return object : RequestBody() {
override fun contentType(): MediaType? {
return mediaType
}
override fun contentType(): MediaType? = mediaType

override fun contentLength(): Long {
return length
}
override fun contentLength(): Long = length

override fun isOneShot(): Boolean {
return !repeatable()
}
override fun isOneShot(): Boolean = !repeatable()

override fun writeTo(sink: BufferedSink) {
writeTo(sink.outputStream())
}
override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
}
}

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

return object : HttpResponse {
override fun statusCode(): Int {
return code
}
override fun statusCode(): Int = code

override fun headers(): ListMultimap<String, String> {
return headers
}
override fun headers(): ListMultimap<String, String> = headers

override fun body(): InputStream {
return body!!.byteStream()
}
override fun body(): InputStream = body!!.byteStream()

override fun close() {
body!!.close()
}
override fun close() = body!!.close()
}
}

Expand All @@ -153,9 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
.arrayListValues()
.build<String, String>()

forEach { pair -> headers.put(pair.first, pair.second) }

return headers
}

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

private var baseUrl: HttpUrl? = null
// default timeout is 1 minute
// The default timeout is 1 minute.
private var timeout: Duration = Duration.ofSeconds(60)
private var proxy: Proxy? = null

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

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

fun build(): OkHttpClient {
return OkHttpClient(
fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
.connectTimeout(timeout)
.readTimeout(timeout)
Expand All @@ -187,7 +169,6 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
.build(),
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
)
}
}

private suspend fun Call.executeAsync(): Response =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OmnistackOkHttpClient private constructor() {

private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var baseUrl: String = ClientOptions.PRODUCTION_URL
// default timeout for client is 1 minute
// The default timeout for the client is 1 minute.
private var timeout: Duration = Duration.ofSeconds(60)
private var proxy: Proxy? = null

Expand Down Expand Up @@ -52,6 +52,24 @@ class OmnistackOkHttpClient private constructor() {

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

fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.queryParams(queryParams)
}

fun putQueryParam(key: String, value: String) = apply {
clientOptions.putQueryParam(key, value)
}

fun putQueryParams(key: String, values: Iterable<String>) = apply {
clientOptions.putQueryParams(key, values)
}

fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.putAllQueryParams(queryParams)
}

fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) }

fun timeout(timeout: Duration) = apply { this.timeout = timeout }

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

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

fun build(): OmnistackClient {
return OmnistackClientImpl(
fun build(): OmnistackClient =
OmnistackClientImpl(
clientOptions
.httpClient(
OkHttpClient.builder()
Expand All @@ -78,6 +96,5 @@ class OmnistackOkHttpClient private constructor() {
)
.build()
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OmnistackOkHttpClientAsync private constructor() {

private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var baseUrl: String = ClientOptions.PRODUCTION_URL
// default timeout for client is 1 minute
// The default timeout for the client is 1 minute.
private var timeout: Duration = Duration.ofSeconds(60)
private var proxy: Proxy? = null

Expand Down Expand Up @@ -52,6 +52,24 @@ class OmnistackOkHttpClientAsync private constructor() {

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

fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.queryParams(queryParams)
}

fun putQueryParam(key: String, value: String) = apply {
clientOptions.putQueryParam(key, value)
}

fun putQueryParams(key: String, values: Iterable<String>) = apply {
clientOptions.putQueryParams(key, values)
}

fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.putAllQueryParams(queryParams)
}

fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) }

fun timeout(timeout: Duration) = apply { this.timeout = timeout }

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

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

fun build(): OmnistackClientAsync {
return OmnistackClientAsyncImpl(
fun build(): OmnistackClientAsync =
OmnistackClientAsyncImpl(
clientOptions
.httpClient(
OkHttpClient.builder()
Expand All @@ -78,6 +96,5 @@ class OmnistackOkHttpClientAsync private constructor() {
)
.build()
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// File generated from our OpenAPI spec by Stainless.

@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102

package com.omnistack.api.client

import com.omnistack.api.models.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// File generated from our OpenAPI spec by Stainless.

@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102

package com.omnistack.api.client

import com.omnistack.api.models.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.omnistack.api.client

import com.omnistack.api.core.ClientOptions
import com.omnistack.api.core.getPackageVersion
import com.omnistack.api.models.*
import com.omnistack.api.services.async.*

Expand All @@ -11,12 +12,21 @@ constructor(
private val clientOptions: ClientOptions,
) : OmnistackClientAsync {

private val clientOptionsWithUserAgent =
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
else
clientOptions
.toBuilder()
.putHeader("User-Agent", "${javaClass.simpleName}/Kotlin ${getPackageVersion()}")
.build()

// Pass the original clientOptions so that this client sets its own User-Agent.
private val sync: OmnistackClient by lazy { OmnistackClientImpl(clientOptions) }

private val chats: ChatServiceAsync by lazy { ChatServiceAsyncImpl(clientOptions) }
private val chats: ChatServiceAsync by lazy { ChatServiceAsyncImpl(clientOptionsWithUserAgent) }

private val completions: CompletionServiceAsync by lazy {
CompletionServiceAsyncImpl(clientOptions)
CompletionServiceAsyncImpl(clientOptionsWithUserAgent)
}

override fun sync(): OmnistackClient = sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.omnistack.api.client

import com.omnistack.api.core.ClientOptions
import com.omnistack.api.core.getPackageVersion
import com.omnistack.api.models.*
import com.omnistack.api.services.blocking.*

Expand All @@ -11,11 +12,22 @@ constructor(
private val clientOptions: ClientOptions,
) : OmnistackClient {

private val clientOptionsWithUserAgent =
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
else
clientOptions
.toBuilder()
.putHeader("User-Agent", "${javaClass.simpleName}/Kotlin ${getPackageVersion()}")
.build()

// Pass the original clientOptions so that this client sets its own User-Agent.
private val async: OmnistackClientAsync by lazy { OmnistackClientAsyncImpl(clientOptions) }

private val chats: ChatService by lazy { ChatServiceImpl(clientOptions) }
private val chats: ChatService by lazy { ChatServiceImpl(clientOptionsWithUserAgent) }

private val completions: CompletionService by lazy { CompletionServiceImpl(clientOptions) }
private val completions: CompletionService by lazy {
CompletionServiceImpl(clientOptionsWithUserAgent)
}

override fun async(): OmnistackClientAsync = async

Expand Down
Loading

0 comments on commit aa6fca3

Please sign in to comment.