Skip to content

Commit ed455e3

Browse files
stainless-botStainless Bot
authored andcommitted
feat(client): propagate headers/query params methods to client builders
chore: unknown commit message
1 parent bf7b4a2 commit ed455e3

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ class OpenAIOkHttpClient 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) }

openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ class OpenAIOkHttpClientAsync 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) }

openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ private constructor(
9696
putAllQueryParams(queryParams)
9797
}
9898

99-
fun putQueryParam(name: String, value: String) = apply { queryParams.put(name, value) }
99+
fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) }
100100

101-
fun putQueryParams(name: String, values: Iterable<String>) = apply {
102-
queryParams.putAll(name, values)
101+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
102+
queryParams.putAll(key, values)
103103
}
104104

105105
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
106106
queryParams.forEach(::putQueryParams)
107107
}
108108

109-
fun removeQueryParam(name: String) = apply { queryParams.removeAll(name) }
109+
fun removeQueryParam(key: String) = apply { queryParams.removeAll(key) }
110110

111111
fun responseValidation(responseValidation: Boolean) = apply {
112112
this.responseValidation = responseValidation

0 commit comments

Comments
 (0)