Skip to content

Commit cd40b00

Browse files
chore: rebuild project due to codegen change (#45)
1 parent c97f231 commit cd40b00

File tree

68 files changed

+2658
-888
lines changed

Some content is hidden

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

68 files changed

+2658
-888
lines changed

openlayer-java-client-okhttp/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ plugins {
66
dependencies {
77
api(project(":openlayer-java-core"))
88

9-
implementation("com.google.guava:guava:33.0.0-jre")
109
implementation("com.squareup.okhttp3:okhttp:4.12.0")
1110

1211
testImplementation(kotlin("test"))

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

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.openlayer.api.client.okhttp
22

3-
import com.google.common.collect.ListMultimap
4-
import com.google.common.collect.MultimapBuilder
53
import com.openlayer.api.core.RequestOptions
4+
import com.openlayer.api.core.http.Headers
65
import com.openlayer.api.core.http.HttpClient
76
import com.openlayer.api.core.http.HttpMethod
87
import com.openlayer.api.core.http.HttpRequest
@@ -16,7 +15,6 @@ import java.time.Duration
1615
import java.util.concurrent.CompletableFuture
1716
import okhttp3.Call
1817
import okhttp3.Callback
19-
import okhttp3.Headers
2018
import okhttp3.HttpUrl
2119
import okhttp3.HttpUrl.Companion.toHttpUrl
2220
import okhttp3.MediaType
@@ -95,7 +93,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
9593
}
9694

9795
val builder = Request.Builder().url(toUrl()).method(method.name, body)
98-
headers.forEach(builder::header)
96+
headers.names().forEach { name ->
97+
headers.values(name).forEach { builder.header(name, it) }
98+
}
9999

100100
return builder.build()
101101
}
@@ -107,7 +107,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
107107

108108
val builder = baseUrl.newBuilder()
109109
pathSegments.forEach(builder::addPathSegment)
110-
queryParams.forEach(builder::addQueryParameter)
110+
queryParams.keys().forEach { key ->
111+
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
112+
}
111113

112114
return builder.toString()
113115
}
@@ -133,21 +135,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
133135
return object : HttpResponse {
134136
override fun statusCode(): Int = code
135137

136-
override fun headers(): ListMultimap<String, String> = headers
138+
override fun headers(): Headers = headers
137139

138140
override fun body(): InputStream = body!!.byteStream()
139141

140142
override fun close() = body!!.close()
141143
}
142144
}
143145

144-
private fun Headers.toHeaders(): ListMultimap<String, String> {
145-
val headers =
146-
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
147-
.arrayListValues()
148-
.build<String, String>()
149-
forEach { pair -> headers.put(pair.first, pair.second) }
150-
return headers
146+
private fun okhttp3.Headers.toHeaders(): Headers {
147+
val headersBuilder = Headers.builder()
148+
forEach { (name, value) -> headersBuilder.put(name, value) }
149+
return headersBuilder.build()
151150
}
152151

153152
companion object {

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

+67-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
66
import com.openlayer.api.client.OpenlayerClient
77
import com.openlayer.api.client.OpenlayerClientImpl
88
import com.openlayer.api.core.ClientOptions
9+
import com.openlayer.api.core.http.Headers
10+
import com.openlayer.api.core.http.QueryParams
911
import java.net.Proxy
1012
import java.time.Clock
1113
import java.time.Duration
@@ -36,6 +38,8 @@ class OpenlayerOkHttpClient private constructor() {
3638

3739
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
3840

41+
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
42+
3943
fun headers(headers: Map<String, Iterable<String>>) = apply {
4044
clientOptions.headers(headers)
4145
}
@@ -46,11 +50,73 @@ class OpenlayerOkHttpClient private constructor() {
4650
clientOptions.putHeaders(name, values)
4751
}
4852

53+
fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) }
54+
4955
fun putAllHeaders(headers: Map<String, Iterable<String>>) = apply {
5056
clientOptions.putAllHeaders(headers)
5157
}
5258

53-
fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) }
59+
fun replaceHeaders(name: String, value: String) = apply {
60+
clientOptions.replaceHeaders(name, value)
61+
}
62+
63+
fun replaceHeaders(name: String, values: Iterable<String>) = apply {
64+
clientOptions.replaceHeaders(name, values)
65+
}
66+
67+
fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) }
68+
69+
fun replaceAllHeaders(headers: Map<String, Iterable<String>>) = apply {
70+
clientOptions.replaceAllHeaders(headers)
71+
}
72+
73+
fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) }
74+
75+
fun removeAllHeaders(names: Set<String>) = apply { clientOptions.removeAllHeaders(names) }
76+
77+
fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) }
78+
79+
fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
80+
clientOptions.queryParams(queryParams)
81+
}
82+
83+
fun putQueryParam(key: String, value: String) = apply {
84+
clientOptions.putQueryParam(key, value)
85+
}
86+
87+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
88+
clientOptions.putQueryParams(key, values)
89+
}
90+
91+
fun putAllQueryParams(queryParams: QueryParams) = apply {
92+
clientOptions.putAllQueryParams(queryParams)
93+
}
94+
95+
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
96+
clientOptions.putAllQueryParams(queryParams)
97+
}
98+
99+
fun replaceQueryParams(key: String, value: String) = apply {
100+
clientOptions.replaceQueryParams(key, value)
101+
}
102+
103+
fun replaceQueryParams(key: String, values: Iterable<String>) = apply {
104+
clientOptions.replaceQueryParams(key, values)
105+
}
106+
107+
fun replaceAllQueryParams(queryParams: QueryParams) = apply {
108+
clientOptions.replaceAllQueryParams(queryParams)
109+
}
110+
111+
fun replaceAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
112+
clientOptions.replaceAllQueryParams(queryParams)
113+
}
114+
115+
fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) }
116+
117+
fun removeAllQueryParams(keys: Set<String>) = apply {
118+
clientOptions.removeAllQueryParams(keys)
119+
}
54120

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

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

+67-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
66
import com.openlayer.api.client.OpenlayerClientAsync
77
import com.openlayer.api.client.OpenlayerClientAsyncImpl
88
import com.openlayer.api.core.ClientOptions
9+
import com.openlayer.api.core.http.Headers
10+
import com.openlayer.api.core.http.QueryParams
911
import java.net.Proxy
1012
import java.time.Clock
1113
import java.time.Duration
@@ -36,6 +38,8 @@ class OpenlayerOkHttpClientAsync private constructor() {
3638

3739
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
3840

41+
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
42+
3943
fun headers(headers: Map<String, Iterable<String>>) = apply {
4044
clientOptions.headers(headers)
4145
}
@@ -46,11 +50,73 @@ class OpenlayerOkHttpClientAsync private constructor() {
4650
clientOptions.putHeaders(name, values)
4751
}
4852

53+
fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) }
54+
4955
fun putAllHeaders(headers: Map<String, Iterable<String>>) = apply {
5056
clientOptions.putAllHeaders(headers)
5157
}
5258

53-
fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) }
59+
fun replaceHeaders(name: String, value: String) = apply {
60+
clientOptions.replaceHeaders(name, value)
61+
}
62+
63+
fun replaceHeaders(name: String, values: Iterable<String>) = apply {
64+
clientOptions.replaceHeaders(name, values)
65+
}
66+
67+
fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) }
68+
69+
fun replaceAllHeaders(headers: Map<String, Iterable<String>>) = apply {
70+
clientOptions.replaceAllHeaders(headers)
71+
}
72+
73+
fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) }
74+
75+
fun removeAllHeaders(names: Set<String>) = apply { clientOptions.removeAllHeaders(names) }
76+
77+
fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) }
78+
79+
fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
80+
clientOptions.queryParams(queryParams)
81+
}
82+
83+
fun putQueryParam(key: String, value: String) = apply {
84+
clientOptions.putQueryParam(key, value)
85+
}
86+
87+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
88+
clientOptions.putQueryParams(key, values)
89+
}
90+
91+
fun putAllQueryParams(queryParams: QueryParams) = apply {
92+
clientOptions.putAllQueryParams(queryParams)
93+
}
94+
95+
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
96+
clientOptions.putAllQueryParams(queryParams)
97+
}
98+
99+
fun replaceQueryParams(key: String, value: String) = apply {
100+
clientOptions.replaceQueryParams(key, value)
101+
}
102+
103+
fun replaceQueryParams(key: String, values: Iterable<String>) = apply {
104+
clientOptions.replaceQueryParams(key, values)
105+
}
106+
107+
fun replaceAllQueryParams(queryParams: QueryParams) = apply {
108+
clientOptions.replaceAllQueryParams(queryParams)
109+
}
110+
111+
fun replaceAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
112+
clientOptions.replaceAllQueryParams(queryParams)
113+
}
114+
115+
fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) }
116+
117+
fun removeAllQueryParams(keys: Set<String>) = apply {
118+
clientOptions.removeAllQueryParams(keys)
119+
}
54120

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

openlayer-java-core/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ plugins {
66
dependencies {
77
api("com.fasterxml.jackson.core:jackson-core:2.14.3")
88
api("com.fasterxml.jackson.core:jackson-databind:2.14.3")
9-
api("com.google.guava:guava:33.0.0-jre")
109

1110
implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3")
1211
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ constructor(
1313
) : OpenlayerClientAsync {
1414

1515
private val clientOptionsWithUserAgent =
16-
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
16+
if (clientOptions.headers.names().contains("User-Agent")) clientOptions
1717
else
1818
clientOptions
1919
.toBuilder()

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ constructor(
1313
) : OpenlayerClient {
1414

1515
private val clientOptionsWithUserAgent =
16-
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
16+
if (clientOptions.headers.names().contains("User-Agent")) clientOptions
1717
else
1818
clientOptions
1919
.toBuilder()

0 commit comments

Comments
 (0)