Skip to content

Commit

Permalink
chore: update SDK settings (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Oct 1, 2024
1 parent 515b9f0 commit 9e75555
Show file tree
Hide file tree
Showing 395 changed files with 63,552 additions and 64,138 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,25 @@ jobs:

- name: Run lints
run: ./scripts/lint
test:
name: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
8
17
cache: gradle

- name: Set up Gradle
uses: gradle/gradle-build-action@v2

- name: Run tests
run: ./scripts/test

2 changes: 2 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 88
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-9eeeeb30b963f3f5672794f8a99ccc3e67d4bb08639514a2c66bc9baf5942a06.yml
configured_endpoints: 87
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-d61f2ff056a756a7e0a176a137c86e1e2e77f51b87420ccc114e2c584c4fa9e5.yml
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/).

## Documentation

The REST API documentation can be found [on www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec).
The REST API documentation can be found on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec).

---

Expand Down Expand Up @@ -84,7 +84,9 @@ then pass that to the `create` method of the `projects` service.
import com.braintrustdata.api.models.Project;
import com.braintrustdata.api.models.ProjectCreateParams;

ProjectCreateParams params = ProjectCreateParams.builder().build();
ProjectCreateParams params = ProjectCreateParams.builder()
.name("foobar")
.build();
Project project = client.projects().create(params);
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package com.braintrustdata.api.client.okhttp

import com.google.common.collect.ListMultimap
import com.google.common.collect.MultimapBuilder
import com.braintrustdata.api.core.RequestOptions
import com.braintrustdata.api.core.http.HttpClient
import com.braintrustdata.api.core.http.HttpMethod
import com.braintrustdata.api.core.http.HttpRequest
import com.braintrustdata.api.core.http.HttpRequestBody
import com.braintrustdata.api.core.http.HttpResponse
import com.braintrustdata.api.core.http.HttpMethod
import com.braintrustdata.api.errors.BraintrustIoException
import com.google.common.collect.ListMultimap
import com.google.common.collect.MultimapBuilder
import java.io.IOException
import java.io.InputStream
import java.net.Proxy
import java.time.Duration
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl
import okhttp3.Response
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.MediaType
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okio.BufferedSink

class OkHttpClient
Expand All @@ -34,7 +33,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient {
val timeout = requestOptions.timeout ?: return okHttpClient
return okHttpClient.newBuilder()
return okHttpClient
.newBuilder()
.connectTimeout(timeout)
.readTimeout(timeout)
.writeTimeout(timeout)
Expand Down Expand Up @@ -76,7 +76,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
override fun onFailure(call: Call, e: IOException) {
future.completeExceptionally(BraintrustIoException("Request failed", e))
}
})
}
)

return future
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,8 @@

package com.braintrustdata.api.client

import java.time.Duration
import java.util.Base64
import java.util.Optional
import java.util.concurrent.CompletableFuture
import com.braintrustdata.api.core.ClientOptions
import com.braintrustdata.api.core.http.HttpMethod
import com.braintrustdata.api.core.http.HttpRequest
import com.braintrustdata.api.core.http.HttpResponse.Handler
import com.braintrustdata.api.core.JsonField
import com.braintrustdata.api.core.RequestOptions
import com.braintrustdata.api.errors.BraintrustError
import com.braintrustdata.api.errors.BraintrustInvalidDataException
import com.braintrustdata.api.models.*
import com.braintrustdata.api.services.blocking.*
import com.braintrustdata.api.services.emptyHandler
import com.braintrustdata.api.services.errorHandler
import com.braintrustdata.api.services.json
import com.braintrustdata.api.services.jsonHandler
import com.braintrustdata.api.services.stringHandler
import com.braintrustdata.api.services.binaryHandler
import com.braintrustdata.api.services.withErrorHandler

interface BraintrustClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,8 @@

package com.braintrustdata.api.client

import java.time.Duration
import java.util.Base64
import java.util.Optional
import java.util.concurrent.CompletableFuture
import com.braintrustdata.api.core.ClientOptions
import com.braintrustdata.api.core.http.HttpMethod
import com.braintrustdata.api.core.http.HttpRequest
import com.braintrustdata.api.core.http.HttpResponse.Handler
import com.braintrustdata.api.core.JsonField
import com.braintrustdata.api.core.RequestOptions
import com.braintrustdata.api.errors.BraintrustError
import com.braintrustdata.api.errors.BraintrustInvalidDataException
import com.braintrustdata.api.models.*
import com.braintrustdata.api.services.async.*
import com.braintrustdata.api.services.emptyHandler
import com.braintrustdata.api.services.errorHandler
import com.braintrustdata.api.services.json
import com.braintrustdata.api.services.jsonHandler
import com.braintrustdata.api.services.stringHandler
import com.braintrustdata.api.services.binaryHandler
import com.braintrustdata.api.services.withErrorHandler

interface BraintrustClientAsync {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,17 @@

package com.braintrustdata.api.client

import java.time.Duration
import java.util.Base64
import java.util.Optional
import java.util.concurrent.CompletableFuture
import com.braintrustdata.api.core.ClientOptions
import com.braintrustdata.api.core.http.HttpMethod
import com.braintrustdata.api.core.http.HttpRequest
import com.braintrustdata.api.core.http.HttpResponse.Handler
import com.braintrustdata.api.core.JsonField
import com.braintrustdata.api.core.RequestOptions
import com.braintrustdata.api.errors.BraintrustError
import com.braintrustdata.api.errors.BraintrustInvalidDataException
import com.braintrustdata.api.models.*
import com.braintrustdata.api.services.async.*
import com.braintrustdata.api.services.emptyHandler
import com.braintrustdata.api.services.errorHandler
import com.braintrustdata.api.services.json
import com.braintrustdata.api.services.jsonHandler
import com.braintrustdata.api.services.stringHandler
import com.braintrustdata.api.services.binaryHandler
import com.braintrustdata.api.services.withErrorHandler

class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOptions, ) : BraintrustClientAsync {
class BraintrustClientAsyncImpl
constructor(
private val clientOptions: ClientOptions,
) : BraintrustClientAsync {

private val errorHandler: Handler<BraintrustError> = errorHandler(clientOptions.jsonMapper)

Expand All @@ -34,7 +22,9 @@ class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOpt

private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) }

private val experiments: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptions) }
private val experiments: ExperimentServiceAsync by lazy {
ExperimentServiceAsyncImpl(clientOptions)
}

private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) }

Expand All @@ -48,15 +38,21 @@ class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOpt

private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) }

private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptions) }
private val projectScores: ProjectScoreServiceAsync by lazy {
ProjectScoreServiceAsyncImpl(clientOptions)
}

private val projectTags: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptions) }
private val projectTags: ProjectTagServiceAsync by lazy {
ProjectTagServiceAsyncImpl(clientOptions)
}

private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptions) }

private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) }

private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptions) }
private val organizations: OrganizationServiceAsync by lazy {
OrganizationServiceAsyncImpl(clientOptions)
}

private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,17 @@

package com.braintrustdata.api.client

import java.time.Duration
import java.util.Base64
import java.util.Optional
import java.util.concurrent.CompletableFuture
import com.braintrustdata.api.core.ClientOptions
import com.braintrustdata.api.core.http.HttpMethod
import com.braintrustdata.api.core.http.HttpRequest
import com.braintrustdata.api.core.http.HttpResponse.Handler
import com.braintrustdata.api.core.JsonField
import com.braintrustdata.api.core.RequestOptions
import com.braintrustdata.api.errors.BraintrustError
import com.braintrustdata.api.errors.BraintrustInvalidDataException
import com.braintrustdata.api.models.*
import com.braintrustdata.api.services.blocking.*
import com.braintrustdata.api.services.emptyHandler
import com.braintrustdata.api.services.errorHandler
import com.braintrustdata.api.services.json
import com.braintrustdata.api.services.jsonHandler
import com.braintrustdata.api.services.stringHandler
import com.braintrustdata.api.services.binaryHandler
import com.braintrustdata.api.services.withErrorHandler

class BraintrustClientImpl constructor(private val clientOptions: ClientOptions, ) : BraintrustClient {
class BraintrustClientImpl
constructor(
private val clientOptions: ClientOptions,
) : BraintrustClient {

private val errorHandler: Handler<BraintrustError> = errorHandler(clientOptions.jsonMapper)

Expand All @@ -48,15 +36,19 @@ class BraintrustClientImpl constructor(private val clientOptions: ClientOptions,

private val users: UserService by lazy { UserServiceImpl(clientOptions) }

private val projectScores: ProjectScoreService by lazy { ProjectScoreServiceImpl(clientOptions) }
private val projectScores: ProjectScoreService by lazy {
ProjectScoreServiceImpl(clientOptions)
}

private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptions) }

private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptions) }

private val views: ViewService by lazy { ViewServiceImpl(clientOptions) }

private val organizations: OrganizationService by lazy { OrganizationServiceImpl(clientOptions) }
private val organizations: OrganizationService by lazy {
OrganizationServiceImpl(clientOptions)
}

private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptions) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import com.fasterxml.jackson.databind.deser.ContextualDeserializer
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
import kotlin.reflect.KClass

abstract class BaseDeserializer<T : Any>(type: KClass<T>) : StdDeserializer<T>(type.java), ContextualDeserializer {
abstract class BaseDeserializer<T : Any>(type: KClass<T>) :
StdDeserializer<T>(type.java), ContextualDeserializer {

override fun createContextual(context: DeserializationContext, property: BeanProperty?): JsonDeserializer<T> {
override fun createContextual(
context: DeserializationContext,
property: BeanProperty?
): JsonDeserializer<T> {
return this
}

Expand All @@ -25,7 +29,11 @@ abstract class BaseDeserializer<T : Any>(type: KClass<T>) : StdDeserializer<T>(t

protected abstract fun ObjectCodec.deserialize(node: JsonNode): T

protected fun <T> ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference<T>, validate: (T) -> Unit = {}): T? {
protected fun <T> ObjectCodec.tryDeserialize(
node: JsonNode,
type: TypeReference<T>,
validate: (T) -> Unit = {}
): T? {
return try {
readValue(treeAsTokens(node), type).apply(validate)
} catch (e: JsonMappingException) {
Expand All @@ -35,7 +43,11 @@ abstract class BaseDeserializer<T : Any>(type: KClass<T>) : StdDeserializer<T>(t
}
}

protected fun <T> ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType, validate: (T) -> Unit = {}): T? {
protected fun <T> ObjectCodec.tryDeserialize(
node: JsonNode,
type: JavaType,
validate: (T) -> Unit = {}
): T? {
return try {
readValue<T>(treeAsTokens(node), type).apply(validate)
} catch (e: JsonMappingException) {
Expand Down
Loading

0 comments on commit 9e75555

Please sign in to comment.