Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #19

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 59
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-kotlin-a44e16cb39fc991e410266961f87e6a48c4f9041060cd9e2bdcefe2f4bef9abc.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-a44e16cb39fc991e410266961f87e6a48c4f9041060cd9e2bdcefe2f4bef9abc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ private constructor(
val baseUrl: String,
val apiKey: String,
val headers: ListMultimap<String, String>,
val queryParams: ListMultimap<String, String>,
val responseValidation: Boolean,
) {

Expand All @@ -36,6 +37,7 @@ private constructor(
private var clock: Clock = Clock.systemUTC()
private var baseUrl: String = PRODUCTION_URL
private var headers: MutableMap<String, MutableList<String>> = mutableMapOf()
private var queryParams: MutableMap<String, MutableList<String>> = mutableMapOf()
private var responseValidation: Boolean = false
private var maxRetries: Int = 2
private var apiKey: String? = null
Expand Down Expand Up @@ -67,6 +69,25 @@ private constructor(

fun removeHeader(name: String) = apply { this.headers.put(name, mutableListOf()) }

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

fun putQueryParam(name: String, value: String) = apply {
this.queryParams.getOrPut(name) { mutableListOf() }.add(value)
}

fun putQueryParams(name: String, values: Iterable<String>) = apply {
this.queryParams.getOrPut(name) { mutableListOf() }.addAll(values)
}

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

fun removeQueryParam(name: String) = apply { this.queryParams.put(name, mutableListOf()) }

fun responseValidation(responseValidation: Boolean) = apply {
this.responseValidation = responseValidation
}
Expand All @@ -82,6 +103,7 @@ private constructor(
checkNotNull(apiKey) { "`apiKey` is required but was not set" }

val headers = ArrayListMultimap.create<String, String>()
val queryParams = ArrayListMultimap.create<String, String>()
headers.put("X-Stainless-Lang", "kotlin")
headers.put("X-Stainless-Arch", getOsArch())
headers.put("X-Stainless-OS", getOsName())
Expand All @@ -92,6 +114,7 @@ private constructor(
headers.put("Authorization", "Bearer ${apiKey}")
}
this.headers.forEach(headers::replaceValues)
this.queryParams.forEach(queryParams::replaceValues)

return ClientOptions(
RetryingHttpClient.builder()
Expand All @@ -104,6 +127,7 @@ private constructor(
baseUrl,
apiKey!!,
headers.toUnmodifiable(),
queryParams.toUnmodifiable(),
responseValidation,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "acl")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand All @@ -64,6 +65,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "acl", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -95,6 +97,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "acl")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand All @@ -120,6 +123,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.DELETE)
.addPathSegments("v1", "acl", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -150,6 +154,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PUT)
.addPathSegments("v1", "acl")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "dataset")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -81,6 +82,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "dataset", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -112,6 +114,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PATCH)
.addPathSegments("v1", "dataset", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -144,6 +147,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "dataset")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -172,6 +176,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.DELETE)
.addPathSegments("v1", "dataset", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand All @@ -196,6 +201,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "dataset", params.getPathParam(0), "feedback")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand All @@ -221,6 +227,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "dataset", params.getPathParam(0), "fetch")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -252,6 +259,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "dataset", params.getPathParam(0), "fetch")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -280,6 +288,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "dataset", params.getPathParam(0), "insert")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -313,6 +322,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PUT)
.addPathSegments("v1", "dataset")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -342,6 +352,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "dataset", params.getPathParam(0), "summarize")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "experiment")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -81,6 +82,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "experiment", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -112,6 +114,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PATCH)
.addPathSegments("v1", "experiment", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -144,6 +147,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "experiment")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -172,6 +176,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.DELETE)
.addPathSegments("v1", "experiment", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -199,6 +204,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "experiment", params.getPathParam(0), "feedback")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand All @@ -225,6 +231,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "experiment", params.getPathParam(0), "fetch")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -256,6 +263,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "experiment", params.getPathParam(0), "fetch")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -285,6 +293,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "experiment", params.getPathParam(0), "insert")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -318,6 +327,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PUT)
.addPathSegments("v1", "experiment")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -347,6 +357,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "experiment", params.getPathParam(0), "summarize")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "group")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -68,6 +69,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "group", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -96,6 +98,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PATCH)
.addPathSegments("v1", "group", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -128,6 +131,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "group")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand All @@ -153,6 +157,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.DELETE)
.addPathSegments("v1", "group", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -186,6 +191,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PUT)
.addPathSegments("v1", "group")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.POST)
.addPathSegments("v1", "project")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -77,6 +78,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "project", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -108,6 +110,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PATCH)
.addPathSegments("v1", "project", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -140,6 +143,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("v1", "project")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -168,6 +172,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.DELETE)
.addPathSegments("v1", "project", params.getPathParam(0))
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down Expand Up @@ -201,6 +206,7 @@ constructor(
HttpRequest.builder()
.method(HttpMethod.PUT)
.addPathSegments("v1", "project")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
Expand Down
Loading