Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Oct 1, 2024
1 parent 32fcb82 commit 1849200
Show file tree
Hide file tree
Showing 105 changed files with 7,631 additions and 2,461 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 97
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-35ca662bf69021273747db3b70d40b924819af0f6e01b38001c7c1ae2f8a4712.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-dd60fe261caab803c127a0f29cadcab5f1956be0a5a265100476b972b4b5b62e.yml
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,29 @@ Read the documentation for more configuration options.
### Example: creating a resource

To create a new project, first use the `ProjectCreateParams` builder to specify attributes,
then pass that to the `create` method of the `project` service.
then pass that to the `create` method of the `projects` service.

```java
import com.braintrustdata.api.models.Project;
import com.braintrustdata.api.models.ProjectCreateParams;
import com.braintrustdata.api.models.ProjectModel;

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

### Example: listing resources

The Braintrust API provides a `list` method to get a paginated list of project.
The Braintrust API provides a `list` method to get a paginated list of projects.
You can retrieve the first page by:

```java
import com.braintrustdata.api.models.Page;
import com.braintrustdata.api.models.ProjectModel;
import com.braintrustdata.api.models.Project;

ProjectListPage page = client.project().list();
for (ProjectModel project : page.objects()) {
ProjectListPage page = client.projects().list();
for (Project project : page.objects()) {
System.out.println(project);
}
```
Expand All @@ -107,7 +107,7 @@ See [Pagination](#pagination) below for more information on transparently workin
To make a request to the Braintrust API, you generally build an instance of the appropriate `Params` class.

In [Example: creating a resource](#example-creating-a-resource) above, we used the `ProjectCreateParams.builder()` to pass to
the `create` method of the `project` service.
the `create` method of the `projects` service.

Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case,
you can attach them using the `putAdditionalProperty` method.
Expand All @@ -127,7 +127,7 @@ ProjectCreateParams params = ProjectCreateParams.builder()
When receiving a response, the Braintrust Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `BraintrustInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model.

```java
ProjectModel projectModel = client.project().create().validate();
Project project = client.projects().create().validate();
```

### Response properties as JSON
Expand Down Expand Up @@ -176,13 +176,13 @@ which automatically handles fetching more pages for you:

```java
// As an Iterable:
ProjectListPage page = client.project().list(params);
for (ProjectModel project : page.autoPager()) {
ProjectListPage page = client.projects().list(params);
for (Project project : page.autoPager()) {
System.out.println(project);
};

// As a Stream:
client.project().list(params).autoPager().stream()
client.projects().list(params).autoPager().stream()
.limit(50)
.forEach(project -> System.out.println(project));
```
Expand All @@ -191,7 +191,7 @@ client.project().list(params).autoPager().stream()

```java
// Using forEach, which returns CompletableFuture<Void>:
asyncClient.project().list(params).autoPager()
asyncClient.projects().list(params).autoPager()
.forEach(project -> System.out.println(project), executor);
```

Expand All @@ -203,9 +203,9 @@ A page of results has a `data()` method to fetch the list of objects, as well as
`hasNextPage`, `getNextPage`, and `getNextPageParams` methods to help with pagination.

```java
ProjectListPage page = client.project().list(params);
ProjectListPage page = client.projects().list(params);
while (page != null) {
for (ProjectModel project : page.objects()) {
for (Project project : page.objects()) {
System.out.println(project);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ interface BraintrustClient {

fun topLevel(): TopLevelService

fun project(): ProjectService
fun projects(): ProjectService

fun experiment(): ExperimentService
fun experiments(): ExperimentService

fun dataset(): DatasetService
fun datasets(): DatasetService

fun prompt(): PromptService
fun prompts(): PromptService

fun role(): RoleService
fun roles(): RoleService

fun group(): GroupService
fun groups(): GroupService

fun acl(): AclService
fun acls(): AclService

fun user(): UserService
fun users(): UserService

fun projectScore(): ProjectScoreService
fun projectScores(): ProjectScoreService

fun projectTag(): ProjectTagService
fun projectTags(): ProjectTagService

fun function(): FunctionService
fun functions(): FunctionService

fun view(): ViewService
fun views(): ViewService

fun organization(): OrganizationService
fun organizations(): OrganizationService

fun apiKeyResource(): ApiKeyResourceService
fun apiKeys(): ApiKeyService

fun aiSecret(): AiSecretService
fun aiSecrets(): AiSecretService
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ interface BraintrustClientAsync {

fun topLevel(): TopLevelServiceAsync

fun project(): ProjectServiceAsync
fun projects(): ProjectServiceAsync

fun experiment(): ExperimentServiceAsync
fun experiments(): ExperimentServiceAsync

fun dataset(): DatasetServiceAsync
fun datasets(): DatasetServiceAsync

fun prompt(): PromptServiceAsync
fun prompts(): PromptServiceAsync

fun role(): RoleServiceAsync
fun roles(): RoleServiceAsync

fun group(): GroupServiceAsync
fun groups(): GroupServiceAsync

fun acl(): AclServiceAsync
fun acls(): AclServiceAsync

fun user(): UserServiceAsync
fun users(): UserServiceAsync

fun projectScore(): ProjectScoreServiceAsync
fun projectScores(): ProjectScoreServiceAsync

fun projectTag(): ProjectTagServiceAsync
fun projectTags(): ProjectTagServiceAsync

fun function(): FunctionServiceAsync
fun functions(): FunctionServiceAsync

fun view(): ViewServiceAsync
fun views(): ViewServiceAsync

fun organization(): OrganizationServiceAsync
fun organizations(): OrganizationServiceAsync

fun apiKeyResource(): ApiKeyResourceServiceAsync
fun apiKeys(): ApiKeyServiceAsync

fun aiSecret(): AiSecretServiceAsync
fun aiSecrets(): AiSecretServiceAsync
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,77 +20,75 @@ constructor(

private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptions) }

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

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

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

private val prompt: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) }
private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) }

private val role: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) }
private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) }

private val group: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) }
private val groups: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) }

private val acl: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptions) }
private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptions) }

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

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

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

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

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

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

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

private val aiSecret: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptions) }
private val aiSecrets: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptions) }

override fun sync(): BraintrustClient = sync

override fun topLevel(): TopLevelServiceAsync = topLevel

override fun project(): ProjectServiceAsync = project
override fun projects(): ProjectServiceAsync = projects

override fun experiment(): ExperimentServiceAsync = experiment
override fun experiments(): ExperimentServiceAsync = experiments

override fun dataset(): DatasetServiceAsync = dataset
override fun datasets(): DatasetServiceAsync = datasets

override fun prompt(): PromptServiceAsync = prompt
override fun prompts(): PromptServiceAsync = prompts

override fun role(): RoleServiceAsync = role
override fun roles(): RoleServiceAsync = roles

override fun group(): GroupServiceAsync = group
override fun groups(): GroupServiceAsync = groups

override fun acl(): AclServiceAsync = acl
override fun acls(): AclServiceAsync = acls

override fun user(): UserServiceAsync = user
override fun users(): UserServiceAsync = users

override fun projectScore(): ProjectScoreServiceAsync = projectScore
override fun projectScores(): ProjectScoreServiceAsync = projectScores

override fun projectTag(): ProjectTagServiceAsync = projectTag
override fun projectTags(): ProjectTagServiceAsync = projectTags

override fun function(): FunctionServiceAsync = function
override fun functions(): FunctionServiceAsync = functions

override fun view(): ViewServiceAsync = view
override fun views(): ViewServiceAsync = views

override fun organization(): OrganizationServiceAsync = organization
override fun organizations(): OrganizationServiceAsync = organizations

override fun apiKeyResource(): ApiKeyResourceServiceAsync = apiKeyResource
override fun apiKeys(): ApiKeyServiceAsync = apiKeys

override fun aiSecret(): AiSecretServiceAsync = aiSecret
override fun aiSecrets(): AiSecretServiceAsync = aiSecrets
}
Loading

0 comments on commit 1849200

Please sign in to comment.