diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index da59f99e..3e2bf498 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.4.0"
+ ".": "0.4.1"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 211f3f65..b8ad4101 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## 0.4.1 (2024-11-12)
+
+Full Changelog: [v0.4.0...v0.4.1](https://github.com/orbcorp/orb-java/compare/v0.4.0...v0.4.1)
+
+### Bug Fixes
+
+* **internal:** add missing options ([1ed6c28](https://github.com/orbcorp/orb-java/commit/1ed6c28c1dacee3121ae2fad5645ea84b5486737))
+
+
+### Chores
+
+* rebuild project due to codegen change ([#105](https://github.com/orbcorp/orb-java/issues/105)) ([6c52ea7](https://github.com/orbcorp/orb-java/commit/6c52ea7a17936f5f675d51b1bcc1a3b6d4816c56))
+* rebuild project due to codegen change ([#107](https://github.com/orbcorp/orb-java/issues/107)) ([0365098](https://github.com/orbcorp/orb-java/commit/0365098b47e408203b0bc2bc4d723ef2c577fe60))
+
## 0.4.0 (2024-11-06)
Full Changelog: [v0.3.0...v0.4.0](https://github.com/orbcorp/orb-java/compare/v0.3.0...v0.4.0)
diff --git a/README.md b/README.md
index b7ee9095..b889ebfc 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-[](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.4.0)
+[](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.4.1)
@@ -25,7 +25,7 @@ The REST API documentation can be foundĀ on [docs.withorb.com](https://docs.with
```kotlin
-implementation("com.withorb.api:orb-java:0.4.0")
+implementation("com.withorb.api:orb-java:0.4.1")
```
#### Maven
@@ -34,7 +34,7 @@ implementation("com.withorb.api:orb-java:0.4.0")
com.withorb.api
orb-java
- 0.4.0
+ 0.4.1
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 150045e9..787a98d7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
allprojects {
group = "com.withorb.api"
- version = "0.4.0" // x-release-please-version
+ version = "0.4.1" // x-release-please-version
}
diff --git a/orb-java-client-okhttp/build.gradle.kts b/orb-java-client-okhttp/build.gradle.kts
index 60e24b25..7cb4746d 100644
--- a/orb-java-client-okhttp/build.gradle.kts
+++ b/orb-java-client-okhttp/build.gradle.kts
@@ -6,7 +6,6 @@ plugins {
dependencies {
api(project(":orb-java-core"))
- implementation("com.google.guava:guava:33.0.0-jre")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation(kotlin("test"))
diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt
index 4233c50d..55ceddea 100644
--- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt
+++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt
@@ -1,8 +1,7 @@
package com.withorb.api.client.okhttp
-import com.google.common.collect.ListMultimap
-import com.google.common.collect.MultimapBuilder
import com.withorb.api.core.RequestOptions
+import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.HttpClient
import com.withorb.api.core.http.HttpMethod
import com.withorb.api.core.http.HttpRequest
@@ -16,7 +15,6 @@ import java.time.Duration
import java.util.concurrent.CompletableFuture
import okhttp3.Call
import okhttp3.Callback
-import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
@@ -95,7 +93,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
}
val builder = Request.Builder().url(toUrl()).method(method.name, body)
- headers.forEach(builder::header)
+ headers.names().forEach { name ->
+ headers.values(name).forEach { builder.header(name, it) }
+ }
return builder.build()
}
@@ -107,7 +107,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
val builder = baseUrl.newBuilder()
pathSegments.forEach(builder::addPathSegment)
- queryParams.forEach(builder::addQueryParameter)
+ queryParams.keys().forEach { key ->
+ queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
+ }
return builder.toString()
}
@@ -133,7 +135,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
return object : HttpResponse {
override fun statusCode(): Int = code
- override fun headers(): ListMultimap = headers
+ override fun headers(): Headers = headers
override fun body(): InputStream = body!!.byteStream()
@@ -141,13 +143,10 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
}
}
- private fun Headers.toHeaders(): ListMultimap {
- val headers =
- MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
- .arrayListValues()
- .build()
- forEach { pair -> headers.put(pair.first, pair.second) }
- return headers
+ private fun okhttp3.Headers.toHeaders(): Headers {
+ val headersBuilder = Headers.builder()
+ forEach { (name, value) -> headersBuilder.put(name, value) }
+ return headersBuilder.build()
}
companion object {
diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt
index 50937b67..caf3d2a8 100644
--- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt
+++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.withorb.api.client.OrbClient
import com.withorb.api.client.OrbClientImpl
import com.withorb.api.core.ClientOptions
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import java.net.Proxy
import java.time.Clock
import java.time.Duration
@@ -36,6 +38,8 @@ class OrbOkHttpClient private constructor() {
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
+ fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
+
fun headers(headers: Map>) = apply {
clientOptions.headers(headers)
}
@@ -46,6 +50,8 @@ class OrbOkHttpClient private constructor() {
clientOptions.putHeaders(name, values)
}
+ fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) }
+
fun putAllHeaders(headers: Map>) = apply {
clientOptions.putAllHeaders(headers)
}
@@ -58,6 +64,8 @@ class OrbOkHttpClient private constructor() {
clientOptions.replaceHeaders(name, values)
}
+ fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) }
+
fun replaceAllHeaders(headers: Map>) = apply {
clientOptions.replaceAllHeaders(headers)
}
@@ -66,6 +74,8 @@ class OrbOkHttpClient private constructor() {
fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) }
+ fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) }
+
fun queryParams(queryParams: Map>) = apply {
clientOptions.queryParams(queryParams)
}
@@ -78,6 +88,10 @@ class OrbOkHttpClient private constructor() {
clientOptions.putQueryParams(key, values)
}
+ fun putAllQueryParams(queryParams: QueryParams) = apply {
+ clientOptions.putAllQueryParams(queryParams)
+ }
+
fun putAllQueryParams(queryParams: Map>) = apply {
clientOptions.putAllQueryParams(queryParams)
}
@@ -90,6 +104,10 @@ class OrbOkHttpClient private constructor() {
clientOptions.replaceQueryParams(key, values)
}
+ fun replaceAllQueryParams(queryParams: QueryParams) = apply {
+ clientOptions.replaceAllQueryParams(queryParams)
+ }
+
fun replaceAllQueryParams(queryParams: Map>) = apply {
clientOptions.replaceAllQueryParams(queryParams)
}
diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt
index c489b88d..4c7bfd71 100644
--- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt
+++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.withorb.api.client.OrbClientAsync
import com.withorb.api.client.OrbClientAsyncImpl
import com.withorb.api.core.ClientOptions
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import java.net.Proxy
import java.time.Clock
import java.time.Duration
@@ -36,6 +38,8 @@ class OrbOkHttpClientAsync private constructor() {
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
+ fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
+
fun headers(headers: Map>) = apply {
clientOptions.headers(headers)
}
@@ -46,6 +50,8 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.putHeaders(name, values)
}
+ fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) }
+
fun putAllHeaders(headers: Map>) = apply {
clientOptions.putAllHeaders(headers)
}
@@ -58,6 +64,8 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.replaceHeaders(name, values)
}
+ fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) }
+
fun replaceAllHeaders(headers: Map>) = apply {
clientOptions.replaceAllHeaders(headers)
}
@@ -66,6 +74,8 @@ class OrbOkHttpClientAsync private constructor() {
fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) }
+ fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) }
+
fun queryParams(queryParams: Map>) = apply {
clientOptions.queryParams(queryParams)
}
@@ -78,6 +88,10 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.putQueryParams(key, values)
}
+ fun putAllQueryParams(queryParams: QueryParams) = apply {
+ clientOptions.putAllQueryParams(queryParams)
+ }
+
fun putAllQueryParams(queryParams: Map>) = apply {
clientOptions.putAllQueryParams(queryParams)
}
@@ -90,6 +104,10 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.replaceQueryParams(key, values)
}
+ fun replaceAllQueryParams(queryParams: QueryParams) = apply {
+ clientOptions.replaceAllQueryParams(queryParams)
+ }
+
fun replaceAllQueryParams(queryParams: Map>) = apply {
clientOptions.replaceAllQueryParams(queryParams)
}
diff --git a/orb-java-core/build.gradle.kts b/orb-java-core/build.gradle.kts
index d7528daf..3c8ddaac 100644
--- a/orb-java-core/build.gradle.kts
+++ b/orb-java-core/build.gradle.kts
@@ -6,7 +6,6 @@ plugins {
dependencies {
api("com.fasterxml.jackson.core:jackson-core:2.14.3")
api("com.fasterxml.jackson.core:jackson-databind:2.14.3")
- api("com.google.guava:guava:33.0.0-jre")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3")
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt
index dfdccfab..79985a9a 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt
@@ -13,7 +13,7 @@ constructor(
) : OrbClientAsync {
private val clientOptionsWithUserAgent =
- if (clientOptions.headers.containsKey("User-Agent")) clientOptions
+ if (clientOptions.headers.names().contains("User-Agent")) clientOptions
else
clientOptions
.toBuilder()
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt
index e7b4f104..4bd2d5bb 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt
@@ -13,7 +13,7 @@ constructor(
) : OrbClient {
private val clientOptionsWithUserAgent =
- if (clientOptions.headers.containsKey("User-Agent")) clientOptions
+ if (clientOptions.headers.names().contains("User-Agent")) clientOptions
else
clientOptions
.toBuilder()
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt
index f9daec72..8a27a863 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt
@@ -3,10 +3,10 @@
package com.withorb.api.core
import com.fasterxml.jackson.databind.json.JsonMapper
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.HttpClient
import com.withorb.api.core.http.PhantomReachableClosingHttpClient
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.http.RetryingHttpClient
import java.time.Clock
@@ -17,12 +17,12 @@ private constructor(
@get:JvmName("jsonMapper") val jsonMapper: JsonMapper,
@get:JvmName("clock") val clock: Clock,
@get:JvmName("baseUrl") val baseUrl: String,
- @get:JvmName("apiKey") val apiKey: String,
- @get:JvmName("webhookSecret") val webhookSecret: String?,
- @get:JvmName("headers") val headers: ListMultimap,
- @get:JvmName("queryParams") val queryParams: ListMultimap,
+ @get:JvmName("headers") val headers: Headers,
+ @get:JvmName("queryParams") val queryParams: QueryParams,
@get:JvmName("responseValidation") val responseValidation: Boolean,
@get:JvmName("maxRetries") val maxRetries: Int,
+ @get:JvmName("apiKey") val apiKey: String,
+ @get:JvmName("webhookSecret") val webhookSecret: String?,
) {
fun toBuilder() = Builder().from(this)
@@ -39,11 +39,11 @@ private constructor(
class Builder {
private var httpClient: HttpClient? = null
- private var jsonMapper: JsonMapper? = null
+ private var jsonMapper: JsonMapper = jsonMapper()
private var clock: Clock = Clock.systemUTC()
private var baseUrl: String = PRODUCTION_URL
- private var headers: MutableMap> = mutableMapOf()
- private var queryParams: MutableMap> = mutableMapOf()
+ private var headers: Headers.Builder = Headers.builder()
+ private var queryParams: QueryParams.Builder = QueryParams.builder()
private var responseValidation: Boolean = false
private var maxRetries: Int = 2
private var apiKey: String? = null
@@ -55,14 +55,8 @@ private constructor(
jsonMapper = clientOptions.jsonMapper
clock = clientOptions.clock
baseUrl = clientOptions.baseUrl
- headers =
- clientOptions.headers.asMap().mapValuesTo(mutableMapOf()) { (_, value) ->
- value.toMutableList()
- }
- queryParams =
- clientOptions.queryParams.asMap().mapValuesTo(mutableMapOf()) { (_, value) ->
- value.toMutableList()
- }
+ headers = clientOptions.headers.toBuilder()
+ queryParams = clientOptions.queryParams.toBuilder()
responseValidation = clientOptions.responseValidation
maxRetries = clientOptions.maxRetries
apiKey = clientOptions.apiKey
@@ -73,42 +67,50 @@ private constructor(
fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper }
+ fun clock(clock: Clock) = apply { this.clock = clock }
+
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
- fun clock(clock: Clock) = apply { this.clock = clock }
+ fun headers(headers: Headers) = apply {
+ this.headers.clear()
+ putAllHeaders(headers)
+ }
fun headers(headers: Map>) = apply {
this.headers.clear()
putAllHeaders(headers)
}
- fun putHeader(name: String, value: String) = apply {
- this.headers.getOrPut(name) { mutableListOf() }.add(value)
- }
+ fun putHeader(name: String, value: String) = apply { headers.put(name, value) }
- fun putHeaders(name: String, values: Iterable) = apply {
- this.headers.getOrPut(name) { mutableListOf() }.addAll(values)
- }
+ fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) }
+
+ fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) }
fun putAllHeaders(headers: Map>) = apply {
- headers.forEach(this::putHeaders)
+ this.headers.putAll(headers)
}
- fun replaceHeaders(name: String, value: String) = apply {
- headers.replaceValues(name, listOf(value))
- }
+ fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) }
fun replaceHeaders(name: String, values: Iterable) = apply {
- headers.replaceValues(name, values)
+ headers.replace(name, values)
}
+ fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) }
+
fun replaceAllHeaders(headers: Map>) = apply {
- headers.forEach(::replaceHeaders)
+ this.headers.replaceAll(headers)
}
- fun removeHeaders(name: String) = apply { headers.removeAll(name) }
+ fun removeHeaders(name: String) = apply { headers.remove(name) }
- fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) }
+ fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) }
+
+ fun queryParams(queryParams: QueryParams) = apply {
+ this.queryParams.clear()
+ putAllQueryParams(queryParams)
+ }
fun queryParams(queryParams: Map>) = apply {
this.queryParams.clear()
@@ -118,28 +120,36 @@ private constructor(
fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) }
fun putQueryParams(key: String, values: Iterable) = apply {
- queryParams.putAll(key, values)
+ queryParams.put(key, values)
+ }
+
+ fun putAllQueryParams(queryParams: QueryParams) = apply {
+ this.queryParams.putAll(queryParams)
}
fun putAllQueryParams(queryParams: Map>) = apply {
- queryParams.forEach(this::putQueryParams)
+ this.queryParams.putAll(queryParams)
}
fun replaceQueryParams(key: String, value: String) = apply {
- queryParams.replaceValues(key, listOf(value))
+ queryParams.replace(key, value)
}
fun replaceQueryParams(key: String, values: Iterable) = apply {
- queryParams.replaceValues(key, values)
+ queryParams.replace(key, values)
+ }
+
+ fun replaceAllQueryParams(queryParams: QueryParams) = apply {
+ this.queryParams.replaceAll(queryParams)
}
fun replaceAllQueryParams(queryParams: Map>) = apply {
- queryParams.forEach(::replaceQueryParams)
+ this.queryParams.replaceAll(queryParams)
}
- fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) }
+ fun removeQueryParams(key: String) = apply { queryParams.remove(key) }
- fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) }
+ fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) }
fun responseValidation(responseValidation: Boolean) = apply {
this.responseValidation = responseValidation
@@ -160,8 +170,8 @@ private constructor(
checkNotNull(httpClient) { "`httpClient` is required but was not set" }
checkNotNull(apiKey) { "`apiKey` is required but was not set" }
- val headers = ArrayListMultimap.create()
- val queryParams = ArrayListMultimap.create()
+ val headers = Headers.builder()
+ val queryParams = QueryParams.builder()
headers.put("X-Stainless-Lang", "java")
headers.put("X-Stainless-Arch", getOsArch())
headers.put("X-Stainless-OS", getOsName())
@@ -169,11 +179,13 @@ private constructor(
headers.put("X-Stainless-Package-Version", getPackageVersion())
headers.put("X-Stainless-Runtime", "JRE")
headers.put("X-Stainless-Runtime-Version", getJavaVersion())
- if (!apiKey.isNullOrEmpty()) {
- headers.put("Authorization", "Bearer ${apiKey}")
+ apiKey?.let {
+ if (!it.isEmpty()) {
+ headers.put("Authorization", "Bearer $it")
+ }
}
- this.headers.forEach(headers::replaceValues)
- this.queryParams.forEach(queryParams::replaceValues)
+ headers.replaceAll(this.headers.build())
+ queryParams.replaceAll(this.queryParams.build())
return ClientOptions(
httpClient!!,
@@ -185,15 +197,15 @@ private constructor(
.idempotencyHeader("Idempotency-Key")
.build()
),
- jsonMapper ?: jsonMapper(),
+ jsonMapper,
clock,
baseUrl,
- apiKey!!,
- webhookSecret,
- headers.toImmutable(),
- queryParams.toImmutable(),
+ headers.build(),
+ queryParams.build(),
responseValidation,
maxRetries,
+ apiKey!!,
+ webhookSecret,
)
}
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt
index f576c2da..f63b1594 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt
@@ -2,10 +2,9 @@
package com.withorb.api.core
-import com.google.common.collect.ImmutableListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Collections
+import java.util.SortedMap
@JvmSynthetic
internal fun T?.getOrThrow(name: String): T =
@@ -20,7 +19,8 @@ internal fun Map.toImmutable(): Map =
if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap())
@JvmSynthetic
-internal fun ListMultimap.toImmutable(): ListMultimap =
- ImmutableListMultimap.copyOf(this)
+internal fun , V> SortedMap.toImmutable(): SortedMap =
+ if (isEmpty()) Collections.emptySortedMap()
+ else Collections.unmodifiableSortedMap(toSortedMap(comparator()))
internal interface Enum
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/ErrorHandler.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/ErrorHandler.kt
index 63829e08..b4e8860c 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/ErrorHandler.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/ErrorHandler.kt
@@ -3,7 +3,7 @@
package com.withorb.api.core.handlers
import com.fasterxml.jackson.databind.json.JsonMapper
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.HttpResponse
import com.withorb.api.core.http.HttpResponse.Handler
import com.withorb.api.errors.BadRequestException
@@ -116,7 +116,7 @@ private fun HttpResponse.buffered(): HttpResponse {
return object : HttpResponse {
override fun statusCode(): Int = this@buffered.statusCode()
- override fun headers(): ListMultimap = this@buffered.headers()
+ override fun headers(): Headers = this@buffered.headers()
override fun body(): InputStream = ByteArrayInputStream(body)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/Headers.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/Headers.kt
new file mode 100644
index 00000000..25aa7f71
--- /dev/null
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/Headers.kt
@@ -0,0 +1,92 @@
+package com.withorb.api.core.http
+
+import com.withorb.api.core.toImmutable
+import java.util.TreeMap
+
+class Headers
+private constructor(
+ private val map: Map>,
+ @get:JvmName("size") val size: Int
+) {
+
+ fun isEmpty(): Boolean = map.isEmpty()
+
+ fun names(): Set = map.keys
+
+ fun values(name: String): List = map[name].orEmpty()
+
+ fun toBuilder(): Builder = Builder().putAll(map)
+
+ companion object {
+
+ @JvmStatic fun builder() = Builder()
+ }
+
+ class Builder {
+
+ private val map: MutableMap> =
+ TreeMap(String.CASE_INSENSITIVE_ORDER)
+ private var size: Int = 0
+
+ fun put(name: String, value: String) = apply {
+ map.getOrPut(name) { mutableListOf() }.add(value)
+ size++
+ }
+
+ fun put(name: String, values: Iterable) = apply { values.forEach { put(name, it) } }
+
+ fun putAll(headers: Map>) = apply { headers.forEach(::put) }
+
+ fun putAll(headers: Headers) = apply {
+ headers.names().forEach { put(it, headers.values(it)) }
+ }
+
+ fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size }
+
+ fun removeAll(names: Set) = apply { names.forEach(::remove) }
+
+ fun clear() = apply {
+ map.clear()
+ size = 0
+ }
+
+ fun replace(name: String, value: String) = apply {
+ remove(name)
+ put(name, value)
+ }
+
+ fun replace(name: String, values: Iterable) = apply {
+ remove(name)
+ put(name, values)
+ }
+
+ fun replaceAll(headers: Map>) = apply {
+ headers.forEach(::replace)
+ }
+
+ fun replaceAll(headers: Headers) = apply {
+ headers.names().forEach { replace(it, headers.values(it)) }
+ }
+
+ fun build() =
+ Headers(
+ map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) ->
+ values.toImmutable()
+ }
+ .toImmutable(),
+ size
+ )
+ }
+
+ override fun hashCode(): Int = map.hashCode()
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Headers && map == other.map
+ }
+
+ override fun toString(): String = "Headers{map=$map}"
+}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt
index 5992c4a5..72285efa 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt
@@ -1,8 +1,5 @@
package com.withorb.api.core.http
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
-import com.google.common.collect.MultimapBuilder
import com.withorb.api.core.toImmutable
class HttpRequest
@@ -10,11 +7,13 @@ private constructor(
@get:JvmName("method") val method: HttpMethod,
@get:JvmName("url") val url: String?,
@get:JvmName("pathSegments") val pathSegments: List,
- @get:JvmName("headers") val headers: ListMultimap,
- @get:JvmName("queryParams") val queryParams: ListMultimap,
+ @get:JvmName("headers") val headers: Headers,
+ @get:JvmName("queryParams") val queryParams: QueryParams,
@get:JvmName("body") val body: HttpRequestBody?,
) {
+ fun toBuilder(): Builder = Builder().from(this)
+
override fun toString(): String =
"HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}"
@@ -27,11 +26,20 @@ private constructor(
private var method: HttpMethod? = null
private var url: String? = null
private var pathSegments: MutableList = mutableListOf()
- private var headers: ListMultimap =
- MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build()
- private var queryParams: ListMultimap = ArrayListMultimap.create()
+ private var headers: Headers.Builder = Headers.builder()
+ private var queryParams: QueryParams.Builder = QueryParams.builder()
private var body: HttpRequestBody? = null
+ @JvmSynthetic
+ internal fun from(request: HttpRequest) = apply {
+ method = request.method
+ url = request.url
+ pathSegments = request.pathSegments.toMutableList()
+ headers = request.headers.toBuilder()
+ queryParams = request.queryParams.toBuilder()
+ body = request.body
+ }
+
fun method(method: HttpMethod) = apply { this.method = method }
fun url(url: String) = apply { this.url = url }
@@ -42,6 +50,11 @@ private constructor(
this.pathSegments.addAll(pathSegments)
}
+ fun headers(headers: Headers) = apply {
+ this.headers.clear()
+ putAllHeaders(headers)
+ }
+
fun headers(headers: Map>) = apply {
this.headers.clear()
putAllHeaders(headers)
@@ -49,29 +62,34 @@ private constructor(
fun putHeader(name: String, value: String) = apply { headers.put(name, value) }
- fun putHeaders(name: String, values: Iterable) = apply {
- headers.putAll(name, values)
- }
+ fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) }
+
+ fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) }
fun putAllHeaders(headers: Map>) = apply {
- headers.forEach(::putHeaders)
+ this.headers.putAll(headers)
}
- fun replaceHeaders(name: String, value: String) = apply {
- headers.replaceValues(name, listOf(value))
- }
+ fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) }
fun replaceHeaders(name: String, values: Iterable) = apply {
- headers.replaceValues(name, values)
+ headers.replace(name, values)
}
+ fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) }
+
fun replaceAllHeaders(headers: Map>) = apply {
- headers.forEach(::replaceHeaders)
+ this.headers.replaceAll(headers)
}
- fun removeHeaders(name: String) = apply { headers.removeAll(name) }
+ fun removeHeaders(name: String) = apply { headers.remove(name) }
+
+ fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) }
- fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) }
+ fun queryParams(queryParams: QueryParams) = apply {
+ this.queryParams.clear()
+ putAllQueryParams(queryParams)
+ }
fun queryParams(queryParams: Map>) = apply {
this.queryParams.clear()
@@ -81,28 +99,36 @@ private constructor(
fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) }
fun putQueryParams(key: String, values: Iterable) = apply {
- queryParams.putAll(key, values)
+ queryParams.put(key, values)
+ }
+
+ fun putAllQueryParams(queryParams: QueryParams) = apply {
+ this.queryParams.putAll(queryParams)
}
fun putAllQueryParams(queryParams: Map>) = apply {
- queryParams.forEach(::putQueryParams)
+ this.queryParams.putAll(queryParams)
}
fun replaceQueryParams(key: String, value: String) = apply {
- queryParams.replaceValues(key, listOf(value))
+ queryParams.replace(key, value)
}
fun replaceQueryParams(key: String, values: Iterable) = apply {
- queryParams.replaceValues(key, values)
+ queryParams.replace(key, values)
+ }
+
+ fun replaceAllQueryParams(queryParams: QueryParams) = apply {
+ this.queryParams.replaceAll(queryParams)
}
fun replaceAllQueryParams(queryParams: Map>) = apply {
- queryParams.forEach(::replaceQueryParams)
+ this.queryParams.replaceAll(queryParams)
}
- fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) }
+ fun removeQueryParams(key: String) = apply { queryParams.remove(key) }
- fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) }
+ fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) }
fun body(body: HttpRequestBody) = apply { this.body = body }
@@ -111,8 +137,8 @@ private constructor(
checkNotNull(method) { "`method` is required but was not set" },
url,
pathSegments.toImmutable(),
- headers,
- queryParams.toImmutable(),
+ headers.build(),
+ queryParams.build(),
body,
)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt
index a04c1035..0e062edf 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt
@@ -1,6 +1,5 @@
package com.withorb.api.core.http
-import com.google.common.collect.ListMultimap
import java.io.InputStream
import java.lang.AutoCloseable
@@ -8,7 +7,7 @@ interface HttpResponse : AutoCloseable {
fun statusCode(): Int
- fun headers(): ListMultimap
+ fun headers(): Headers
fun body(): InputStream
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/QueryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/QueryParams.kt
new file mode 100644
index 00000000..53c19d9f
--- /dev/null
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/QueryParams.kt
@@ -0,0 +1,86 @@
+package com.withorb.api.core.http
+
+import com.withorb.api.core.toImmutable
+
+class QueryParams
+private constructor(
+ private val map: Map>,
+ @get:JvmName("size") val size: Int
+) {
+
+ fun isEmpty(): Boolean = map.isEmpty()
+
+ fun keys(): Set = map.keys
+
+ fun values(key: String): List = map[key].orEmpty()
+
+ fun toBuilder(): Builder = Builder().putAll(map)
+
+ companion object {
+
+ @JvmStatic fun builder() = Builder()
+ }
+
+ class Builder {
+
+ private val map: MutableMap> = mutableMapOf()
+ private var size: Int = 0
+
+ fun put(key: String, value: String) = apply {
+ map.getOrPut(key) { mutableListOf() }.add(value)
+ size++
+ }
+
+ fun put(key: String, values: Iterable) = apply { values.forEach { put(key, it) } }
+
+ fun putAll(queryParams: Map>) = apply {
+ queryParams.forEach(::put)
+ }
+
+ fun putAll(queryParams: QueryParams) = apply {
+ queryParams.keys().forEach { put(it, queryParams.values(it)) }
+ }
+
+ fun replace(key: String, value: String) = apply {
+ remove(key)
+ put(key, value)
+ }
+
+ fun replace(key: String, values: Iterable) = apply {
+ remove(key)
+ put(key, values)
+ }
+
+ fun replaceAll(queryParams: Map>) = apply {
+ queryParams.forEach(::replace)
+ }
+
+ fun replaceAll(queryParams: QueryParams) = apply {
+ queryParams.keys().forEach { replace(it, queryParams.values(it)) }
+ }
+
+ fun remove(key: String) = apply { size -= map.remove(key).orEmpty().size }
+
+ fun removeAll(keys: Set) = apply { keys.forEach(::remove) }
+
+ fun clear() = apply {
+ map.clear()
+ size = 0
+ }
+
+ fun build() =
+ QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size)
+ }
+
+ override fun hashCode(): Int = map.hashCode()
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is QueryParams && map == other.map
+ }
+
+ override fun toString(): String = "QueryParams{map=$map}"
+}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt
index 896c3704..820dc233 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt
@@ -35,21 +35,22 @@ private constructor(
return httpClient.execute(request, requestOptions)
}
- maybeAddIdempotencyHeader(request)
+ var modifiedRequest = maybeAddIdempotencyHeader(request)
// Don't send the current retry count in the headers if the caller set their own value.
- val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count")
+ val shouldSendRetryCount =
+ !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count")
var retries = 0
while (true) {
if (shouldSendRetryCount) {
- setRetryCountHeader(request, retries)
+ modifiedRequest = setRetryCountHeader(modifiedRequest, retries)
}
val response =
try {
- val response = httpClient.execute(request, requestOptions)
+ val response = httpClient.execute(modifiedRequest, requestOptions)
if (++retries > maxRetries || !shouldRetry(response)) {
return response
}
@@ -76,10 +77,11 @@ private constructor(
return httpClient.executeAsync(request, requestOptions)
}
- maybeAddIdempotencyHeader(request)
+ val modifiedRequest = maybeAddIdempotencyHeader(request)
// Don't send the current retry count in the headers if the caller set their own value.
- val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count")
+ val shouldSendRetryCount =
+ !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count")
var retries = 0
@@ -87,12 +89,11 @@ private constructor(
request: HttpRequest,
requestOptions: RequestOptions,
): CompletableFuture {
- if (shouldSendRetryCount) {
- setRetryCountHeader(request, retries)
- }
+ val requestWithRetryCount =
+ if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request
return httpClient
- .executeAsync(request, requestOptions)
+ .executeAsync(requestWithRetryCount, requestOptions)
.handleAsync(
fun(
response: HttpResponse?,
@@ -112,7 +113,7 @@ private constructor(
val backoffMillis = getRetryBackoffMillis(retries, response)
return sleepAsync(backoffMillis.toMillis()).thenCompose {
- executeWithRetries(request, requestOptions)
+ executeWithRetries(requestWithRetryCount, requestOptions)
}
},
) {
@@ -122,7 +123,7 @@ private constructor(
.thenCompose(Function.identity())
}
- return executeWithRetries(request, requestOptions)
+ return executeWithRetries(modifiedRequest, requestOptions)
}
override fun close() = httpClient.close()
@@ -132,23 +133,26 @@ private constructor(
// the body data aren't available on subsequent attempts.
request.body?.repeatable() ?: true
- private fun setRetryCountHeader(request: HttpRequest, retries: Int) {
- request.headers.removeAll("x-stainless-retry-count")
- request.headers.put("x-stainless-retry-count", retries.toString())
- }
+ private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest =
+ request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build()
private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}"
- private fun maybeAddIdempotencyHeader(request: HttpRequest) {
- if (idempotencyHeader != null && !request.headers.containsKey(idempotencyHeader)) {
- // Set a header to uniquely identify the request when retried
- request.headers.put(idempotencyHeader, idempotencyKey())
+ private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest {
+ if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) {
+ return request
}
+
+ return request
+ .toBuilder()
+ // Set a header to uniquely identify the request when retried.
+ .putHeader(idempotencyHeader, idempotencyKey())
+ .build()
}
private fun shouldRetry(response: HttpResponse): Boolean {
// Note: this is not a standard header
- val shouldRetryHeader = response.headers().get("x-should-retry").getOrNull(0)
+ val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0)
val statusCode = response.statusCode()
return when {
@@ -180,11 +184,11 @@ private constructor(
?.headers()
?.let { headers ->
headers
- .get("Retry-After-Ms")
+ .values("Retry-After-Ms")
.getOrNull(0)
?.toFloatOrNull()
?.times(TimeUnit.MILLISECONDS.toNanos(1))
- ?: headers.get("Retry-After").getOrNull(0)?.let { retryAfter ->
+ ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter ->
retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1))
?: try {
ChronoUnit.MILLIS.between(
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt
index 07c54cc7..30513518 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt
@@ -1,9 +1,9 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class BadRequestException(
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(400, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt
index 61938270..c8acf740 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt
@@ -1,10 +1,10 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class InternalServerException(
statusCode: Int,
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(statusCode, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt
index 0e55011d..8e4f6cb4 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt
@@ -1,9 +1,9 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class NotFoundException(
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(404, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt
index b925699b..bf1b22ae 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt
@@ -13,14 +13,12 @@ import java.util.Objects
@JsonDeserialize(builder = OrbError.Builder::class)
@NoAutoDetect
class OrbError
-constructor(
- private val additionalProperties: Map,
+private constructor(
+ @JsonAnyGetter
+ @get:JvmName("additionalProperties")
+ val additionalProperties: Map,
) {
- @JsonAnyGetter fun additionalProperties(): Map = additionalProperties
-
- fun toBuilder() = Builder()
-
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -35,6 +33,8 @@ constructor(
override fun toString() = "OrbError{additionalProperties=$additionalProperties}"
+ fun toBuilder() = Builder().from(this)
+
companion object {
@JvmStatic fun builder() = Builder()
@@ -44,22 +44,31 @@ constructor(
private var additionalProperties: MutableMap = mutableMapOf()
- fun from(error: OrbError) = apply { additionalProperties(error.additionalProperties) }
+ @JvmSynthetic
+ internal fun from(orbError: OrbError) = apply {
+ additionalProperties = orbError.additionalProperties.toMutableMap()
+ }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ additionalProperties.put(key, value)
}
fun putAllAdditionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.putAll(additionalProperties)
}
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
fun build(): OrbError = OrbError(additionalProperties.toImmutable())
}
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbServiceException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbServiceException.kt
index 7c8fb8f8..2eafb822 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbServiceException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbServiceException.kt
@@ -1,12 +1,12 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
abstract class OrbServiceException
@JvmOverloads
constructor(
private val statusCode: Int,
- private val headers: ListMultimap,
+ private val headers: Headers,
private val body: String,
private val error: OrbError,
message: String = "$statusCode: $error",
@@ -15,7 +15,7 @@ constructor(
fun statusCode(): Int = statusCode
- fun headers(): ListMultimap = headers
+ fun headers(): Headers = headers
fun body(): String = body
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt
index b2fe41c3..b5d97fd4 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt
@@ -1,9 +1,9 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class PermissionDeniedException(
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(403, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt
index 11f99d0f..cbfd0f5d 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt
@@ -1,9 +1,9 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class RateLimitException(
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(429, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt
index e0199cfc..916c60ef 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt
@@ -1,9 +1,9 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class UnauthorizedException(
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(401, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt
index 1c564753..81b26ef5 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt
@@ -1,10 +1,10 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class UnexpectedStatusCodeException(
statusCode: Int,
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(statusCode, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt
index 420b27ab..818e9ad7 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt
@@ -1,9 +1,9 @@
package com.withorb.api.errors
-import com.google.common.collect.ListMultimap
+import com.withorb.api.core.http.Headers
class UnprocessableEntityException(
- headers: ListMultimap,
+ headers: Headers,
body: String,
error: OrbError,
) : OrbServiceException(422, headers, body, error)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt
index b93399d6..9a78a633 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt
@@ -7,13 +7,13 @@ import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import com.withorb.api.models.*
@@ -26,8 +26,8 @@ constructor(
private val currency: String,
private val type: Type,
private val thresholds: List?,
- private val additionalHeaders: Map>,
- private val additionalQueryParams: Map>,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map,
) {
@@ -49,9 +49,9 @@ constructor(
)
}
- @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
+ @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders
- @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams
+ @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams
fun getPathParam(index: Int): String {
return when (index) {
@@ -160,9 +160,9 @@ constructor(
"AlertCreateForCustomerBody{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}"
}
- fun _additionalHeaders(): Map> = additionalHeaders
+ fun _additionalHeaders(): Headers = additionalHeaders
- fun _additionalQueryParams(): Map> = additionalQueryParams
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
fun _additionalBodyProperties(): Map = additionalBodyProperties
@@ -195,8 +195,8 @@ constructor(
private var currency: String? = null
private var type: Type? = null
private var thresholds: MutableList = mutableListOf()
- private var additionalHeaders: ListMultimap = ArrayListMultimap.create()
- private var additionalQueryParams: ListMultimap = ArrayListMultimap.create()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -227,6 +227,11 @@ constructor(
/** The thresholds that define the values at which the alert will be triggered. */
fun addThreshold(threshold: Threshold) = apply { this.thresholds.add(threshold) }
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -237,29 +242,42 @@ constructor(
}
fun putAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.putAll(name, values)
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::putAdditionalHeaders)
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
- additionalHeaders.replaceValues(name, listOf(value))
+ additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.replaceValues(name, values)
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::replaceAdditionalHeaders)
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) }
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set) = apply {
- names.forEach(::removeAdditionalHeaders)
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
@@ -272,42 +290,48 @@ constructor(
}
fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.putAll(key, values)
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::putAdditionalQueryParams)
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
- additionalQueryParams.replaceValues(key, listOf(value))
+ additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.replaceValues(key, values)
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::replaceAdditionalQueryParams)
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
- fun removeAdditionalQueryParams(key: String) = apply {
- additionalQueryParams.removeAll(key)
- }
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set) = apply {
- keys.forEach(::removeAdditionalQueryParams)
+ additionalQueryParams.removeAll(keys)
}
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
this.additionalBodyProperties.clear()
- this.additionalBodyProperties.putAll(additionalBodyProperties)
+ putAllAdditionalBodyProperties(additionalBodyProperties)
}
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
- this.additionalBodyProperties.put(key, value)
+ additionalBodyProperties.put(key, value)
}
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
@@ -315,20 +339,22 @@ constructor(
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
+ fun removeAdditionalBodyProperty(key: String) = apply {
+ additionalBodyProperties.remove(key)
+ }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalBodyProperty)
+ }
+
fun build(): AlertCreateForCustomerParams =
AlertCreateForCustomerParams(
checkNotNull(customerId) { "`customerId` is required but was not set" },
checkNotNull(currency) { "`currency` is required but was not set" },
checkNotNull(type) { "`type` is required but was not set" },
if (thresholds.size == 0) null else thresholds.toImmutable(),
- additionalHeaders
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
- additionalQueryParams
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt
index fe87013b..058f5396 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt
@@ -7,13 +7,13 @@ import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import com.withorb.api.models.*
@@ -26,8 +26,8 @@ constructor(
private val currency: String,
private val type: Type,
private val thresholds: List?,
- private val additionalHeaders: Map>,
- private val additionalQueryParams: Map>,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map,
) {
@@ -49,9 +49,9 @@ constructor(
)
}
- @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
+ @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders
- @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams
+ @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams
fun getPathParam(index: Int): String {
return when (index) {
@@ -162,9 +162,9 @@ constructor(
"AlertCreateForExternalCustomerBody{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}"
}
- fun _additionalHeaders(): Map> = additionalHeaders
+ fun _additionalHeaders(): Headers = additionalHeaders
- fun _additionalQueryParams(): Map> = additionalQueryParams
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
fun _additionalBodyProperties(): Map = additionalBodyProperties
@@ -197,8 +197,8 @@ constructor(
private var currency: String? = null
private var type: Type? = null
private var thresholds: MutableList = mutableListOf()
- private var additionalHeaders: ListMultimap = ArrayListMultimap.create()
- private var additionalQueryParams: ListMultimap = ArrayListMultimap.create()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -233,6 +233,11 @@ constructor(
/** The thresholds that define the values at which the alert will be triggered. */
fun addThreshold(threshold: Threshold) = apply { this.thresholds.add(threshold) }
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -243,29 +248,42 @@ constructor(
}
fun putAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.putAll(name, values)
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::putAdditionalHeaders)
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
- additionalHeaders.replaceValues(name, listOf(value))
+ additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.replaceValues(name, values)
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::replaceAdditionalHeaders)
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) }
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set) = apply {
- names.forEach(::removeAdditionalHeaders)
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
@@ -278,42 +296,48 @@ constructor(
}
fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.putAll(key, values)
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::putAdditionalQueryParams)
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
- additionalQueryParams.replaceValues(key, listOf(value))
+ additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.replaceValues(key, values)
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::replaceAdditionalQueryParams)
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
- fun removeAdditionalQueryParams(key: String) = apply {
- additionalQueryParams.removeAll(key)
- }
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set) = apply {
- keys.forEach(::removeAdditionalQueryParams)
+ additionalQueryParams.removeAll(keys)
}
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
this.additionalBodyProperties.clear()
- this.additionalBodyProperties.putAll(additionalBodyProperties)
+ putAllAdditionalBodyProperties(additionalBodyProperties)
}
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
- this.additionalBodyProperties.put(key, value)
+ additionalBodyProperties.put(key, value)
}
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
@@ -321,6 +345,14 @@ constructor(
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
+ fun removeAdditionalBodyProperty(key: String) = apply {
+ additionalBodyProperties.remove(key)
+ }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalBodyProperty)
+ }
+
fun build(): AlertCreateForExternalCustomerParams =
AlertCreateForExternalCustomerParams(
checkNotNull(externalCustomerId) {
@@ -329,14 +361,8 @@ constructor(
checkNotNull(currency) { "`currency` is required but was not set" },
checkNotNull(type) { "`type` is required but was not set" },
if (thresholds.size == 0) null else thresholds.toImmutable(),
- additionalHeaders
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
- additionalQueryParams
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt
index 588edcd1..a89d7314 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt
@@ -7,13 +7,13 @@ import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import com.withorb.api.models.*
@@ -26,8 +26,8 @@ constructor(
private val thresholds: List,
private val type: Type,
private val metricId: String?,
- private val additionalHeaders: Map>,
- private val additionalQueryParams: Map>,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map,
) {
@@ -49,9 +49,9 @@ constructor(
)
}
- @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
+ @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders
- @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams
+ @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams
fun getPathParam(index: Int): String {
return when (index) {
@@ -162,9 +162,9 @@ constructor(
"AlertCreateForSubscriptionBody{thresholds=$thresholds, type=$type, metricId=$metricId, additionalProperties=$additionalProperties}"
}
- fun _additionalHeaders(): Map> = additionalHeaders
+ fun _additionalHeaders(): Headers = additionalHeaders
- fun _additionalQueryParams(): Map> = additionalQueryParams
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
fun _additionalBodyProperties(): Map = additionalBodyProperties
@@ -197,8 +197,8 @@ constructor(
private var thresholds: MutableList = mutableListOf()
private var type: Type? = null
private var metricId: String? = null
- private var additionalHeaders: ListMultimap = ArrayListMultimap.create()
- private var additionalQueryParams: ListMultimap = ArrayListMultimap.create()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -230,6 +230,11 @@ constructor(
/** The metric to track usage for. */
fun metricId(metricId: String) = apply { this.metricId = metricId }
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -240,29 +245,42 @@ constructor(
}
fun putAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.putAll(name, values)
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::putAdditionalHeaders)
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
- additionalHeaders.replaceValues(name, listOf(value))
+ additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.replaceValues(name, values)
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::replaceAdditionalHeaders)
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) }
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set) = apply {
- names.forEach(::removeAdditionalHeaders)
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
@@ -275,42 +293,48 @@ constructor(
}
fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.putAll(key, values)
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::putAdditionalQueryParams)
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
- additionalQueryParams.replaceValues(key, listOf(value))
+ additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.replaceValues(key, values)
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::replaceAdditionalQueryParams)
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
- fun removeAdditionalQueryParams(key: String) = apply {
- additionalQueryParams.removeAll(key)
- }
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set) = apply {
- keys.forEach(::removeAdditionalQueryParams)
+ additionalQueryParams.removeAll(keys)
}
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
this.additionalBodyProperties.clear()
- this.additionalBodyProperties.putAll(additionalBodyProperties)
+ putAllAdditionalBodyProperties(additionalBodyProperties)
}
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
- this.additionalBodyProperties.put(key, value)
+ additionalBodyProperties.put(key, value)
}
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
@@ -318,6 +342,14 @@ constructor(
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
+ fun removeAdditionalBodyProperty(key: String) = apply {
+ additionalBodyProperties.remove(key)
+ }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalBodyProperty)
+ }
+
fun build(): AlertCreateForSubscriptionParams =
AlertCreateForSubscriptionParams(
checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" },
@@ -325,14 +357,8 @@ constructor(
.toImmutable(),
checkNotNull(type) { "`type` is required but was not set" },
metricId,
- additionalHeaders
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
- additionalQueryParams
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt
index 058b554c..b3c5323b 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt
@@ -2,10 +2,10 @@
package com.withorb.api.models
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.toImmutable
import com.withorb.api.models.*
import java.util.Objects
@@ -14,8 +14,8 @@ import java.util.Optional
class AlertDisableParams
constructor(
private val alertConfigurationId: String,
- private val additionalHeaders: Map>,
- private val additionalQueryParams: Map>,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map,
) {
@@ -26,9 +26,9 @@ constructor(
return Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
}
- @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
+ @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders
- @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams
+ @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams
fun getPathParam(index: Int): String {
return when (index) {
@@ -37,9 +37,9 @@ constructor(
}
}
- fun _additionalHeaders(): Map> = additionalHeaders
+ fun _additionalHeaders(): Headers = additionalHeaders
- fun _additionalQueryParams(): Map> = additionalQueryParams
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
fun _additionalBodyProperties(): Map = additionalBodyProperties
@@ -69,8 +69,8 @@ constructor(
class Builder {
private var alertConfigurationId: String? = null
- private var additionalHeaders: ListMultimap = ArrayListMultimap.create()
- private var additionalQueryParams: ListMultimap = ArrayListMultimap.create()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -85,6 +85,11 @@ constructor(
this.alertConfigurationId = alertConfigurationId
}
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -95,29 +100,42 @@ constructor(
}
fun putAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.putAll(name, values)
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::putAdditionalHeaders)
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
- additionalHeaders.replaceValues(name, listOf(value))
+ additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.replaceValues(name, values)
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::replaceAdditionalHeaders)
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) }
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set) = apply {
- names.forEach(::removeAdditionalHeaders)
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
@@ -130,42 +148,48 @@ constructor(
}
fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.putAll(key, values)
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::putAdditionalQueryParams)
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
- additionalQueryParams.replaceValues(key, listOf(value))
+ additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.replaceValues(key, values)
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::replaceAdditionalQueryParams)
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
- fun removeAdditionalQueryParams(key: String) = apply {
- additionalQueryParams.removeAll(key)
- }
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set) = apply {
- keys.forEach(::removeAdditionalQueryParams)
+ additionalQueryParams.removeAll(keys)
}
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
this.additionalBodyProperties.clear()
- this.additionalBodyProperties.putAll(additionalBodyProperties)
+ putAllAdditionalBodyProperties(additionalBodyProperties)
}
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
- this.additionalBodyProperties.put(key, value)
+ additionalBodyProperties.put(key, value)
}
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
@@ -173,19 +197,21 @@ constructor(
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
+ fun removeAdditionalBodyProperty(key: String) = apply {
+ additionalBodyProperties.remove(key)
+ }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalBodyProperty)
+ }
+
fun build(): AlertDisableParams =
AlertDisableParams(
checkNotNull(alertConfigurationId) {
"`alertConfigurationId` is required but was not set"
},
- additionalHeaders
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
- additionalQueryParams
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt
index 5a95dec0..0fe4675f 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt
@@ -2,10 +2,10 @@
package com.withorb.api.models
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.toImmutable
import com.withorb.api.models.*
import java.util.Objects
@@ -14,8 +14,8 @@ import java.util.Optional
class AlertEnableParams
constructor(
private val alertConfigurationId: String,
- private val additionalHeaders: Map>,
- private val additionalQueryParams: Map>,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map,
) {
@@ -26,9 +26,9 @@ constructor(
return Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
}
- @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
+ @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders
- @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams
+ @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams
fun getPathParam(index: Int): String {
return when (index) {
@@ -37,9 +37,9 @@ constructor(
}
}
- fun _additionalHeaders(): Map> = additionalHeaders
+ fun _additionalHeaders(): Headers = additionalHeaders
- fun _additionalQueryParams(): Map> = additionalQueryParams
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
fun _additionalBodyProperties(): Map = additionalBodyProperties
@@ -69,8 +69,8 @@ constructor(
class Builder {
private var alertConfigurationId: String? = null
- private var additionalHeaders: ListMultimap = ArrayListMultimap.create()
- private var additionalQueryParams: ListMultimap = ArrayListMultimap.create()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -85,6 +85,11 @@ constructor(
this.alertConfigurationId = alertConfigurationId
}
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -95,29 +100,42 @@ constructor(
}
fun putAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.putAll(name, values)
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::putAdditionalHeaders)
+ this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
- additionalHeaders.replaceValues(name, listOf(value))
+ additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.replaceValues(name, values)
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- additionalHeaders.forEach(::replaceAdditionalHeaders)
+ this.additionalHeaders.replaceAll(additionalHeaders)
}
- fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) }
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set) = apply {
- names.forEach(::removeAdditionalHeaders)
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
@@ -130,42 +148,48 @@ constructor(
}
fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.putAll(key, values)
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::putAdditionalQueryParams)
+ this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
- additionalQueryParams.replaceValues(key, listOf(value))
+ additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.replaceValues(key, values)
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
- additionalQueryParams.forEach(::replaceAdditionalQueryParams)
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
}
- fun removeAdditionalQueryParams(key: String) = apply {
- additionalQueryParams.removeAll(key)
- }
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set) = apply {
- keys.forEach(::removeAdditionalQueryParams)
+ additionalQueryParams.removeAll(keys)
}
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
this.additionalBodyProperties.clear()
- this.additionalBodyProperties.putAll(additionalBodyProperties)
+ putAllAdditionalBodyProperties(additionalBodyProperties)
}
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
- this.additionalBodyProperties.put(key, value)
+ additionalBodyProperties.put(key, value)
}
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
@@ -173,19 +197,21 @@ constructor(
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
+ fun removeAdditionalBodyProperty(key: String) = apply {
+ additionalBodyProperties.remove(key)
+ }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalBodyProperty)
+ }
+
fun build(): AlertEnableParams =
AlertEnableParams(
checkNotNull(alertConfigurationId) {
"`alertConfigurationId` is required but was not set"
},
- additionalHeaders
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
- additionalQueryParams
- .asMap()
- .mapValues { it.value.toList().toImmutable() }
- .toImmutable(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt
index e3c68304..486faa94 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt
@@ -2,10 +2,9 @@
package com.withorb.api.models
-import com.google.common.collect.ArrayListMultimap
-import com.google.common.collect.ListMultimap
import com.withorb.api.core.NoAutoDetect
-import com.withorb.api.core.toImmutable
+import com.withorb.api.core.http.Headers
+import com.withorb.api.core.http.QueryParams
import com.withorb.api.models.*
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
@@ -23,8 +22,8 @@ constructor(
private val externalCustomerId: String?,
private val limit: Long?,
private val subscriptionId: String?,
- private val additionalHeaders: Map>,
- private val additionalQueryParams: Map>,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
) {
fun createdAtGt(): Optional = Optional.ofNullable(createdAtGt)
@@ -45,35 +44,49 @@ constructor(
fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId)
- @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
+ @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders
@JvmSynthetic
- internal fun getQueryParams(): Map> {
- val params = mutableMapOf>()
+ internal fun getQueryParams(): QueryParams {
+ val queryParams = QueryParams.builder()
this.createdAtGt?.let {
- params.put("created_at[gt]", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)))
+ queryParams.put(
+ "created_at[gt]",
+ listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))
+ )
}
this.createdAtGte?.let {
- params.put("created_at[gte]", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)))
+ queryParams.put(
+ "created_at[gte]",
+ listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))
+ )
}
this.createdAtLt?.let {
- params.put("created_at[lt]", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)))
+ queryParams.put(
+ "created_at[lt]",
+ listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))
+ )
}
this.createdAtLte?.let {
- params.put("created_at[lte]", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)))
- }
- this.cursor?.let { params.put("cursor", listOf(it.toString())) }
- this.customerId?.let { params.put("customer_id", listOf(it.toString())) }
- this.externalCustomerId?.let { params.put("external_customer_id", listOf(it.toString())) }
- this.limit?.let { params.put("limit", listOf(it.toString())) }
- this.subscriptionId?.let { params.put("subscription_id", listOf(it.toString())) }
- params.putAll(additionalQueryParams)
- return params.toImmutable()
+ queryParams.put(
+ "created_at[lte]",
+ listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))
+ )
+ }
+ this.cursor?.let { queryParams.put("cursor", listOf(it.toString())) }
+ this.customerId?.let { queryParams.put("customer_id", listOf(it.toString())) }
+ this.externalCustomerId?.let {
+ queryParams.put("external_customer_id", listOf(it.toString()))
+ }
+ this.limit?.let { queryParams.put("limit", listOf(it.toString())) }
+ this.subscriptionId?.let { queryParams.put("subscription_id", listOf(it.toString())) }
+ queryParams.putAll(additionalQueryParams)
+ return queryParams.build()
}
- fun _additionalHeaders(): Map> = additionalHeaders
+ fun _additionalHeaders(): Headers = additionalHeaders
- fun _additionalQueryParams(): Map> = additionalQueryParams
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -109,8 +122,8 @@ constructor(
private var externalCustomerId: String? = null
private var limit: Long? = null
private var subscriptionId: String? = null
- private var additionalHeaders: ListMultimap = ArrayListMultimap.create()
- private var additionalQueryParams: ListMultimap = ArrayListMultimap.create()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@JvmSynthetic
internal fun from(alertListParams: AlertListParams) = apply {
@@ -155,6 +168,11 @@ constructor(
/** Fetch alerts scoped to this subscription_id */
fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId }
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
fun additionalHeaders(additionalHeaders: Map