Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jul 23, 2024
1 parent 9b10b06 commit a4b898c
Show file tree
Hide file tree
Showing 41 changed files with 762 additions and 298 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ 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;

ProjectCreateParams params = ProjectCreateParams.builder().build();
Project project = 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.Project;

ProjectListPage page = client.project().list();
ProjectListPage page = client.projects().list();
for (Project project : page.objects()) {
System.out.println(project);
}
Expand All @@ -114,7 +114,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 @@ -133,7 +133,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
Project project = client.project().create().validate();
Project project = client.projects().create().validate();
```

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

```java
// As an Iterable:
ProjectListPage page = client.project().list(params);
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 @@ -197,7 +197,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 @@ -209,7 +209,7 @@ 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 (Project project : page.objects()) {
System.out.println(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ 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 apiKey(): ApiKeyService
fun apiKeys(): ApiKeyService
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ 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 apiKey(): ApiKeyServiceAsync
fun apiKeys(): ApiKeyServiceAsync
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,63 +32,63 @@ class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOpt

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 { ExperimentServiceAsyncImpl(clientOptions) }
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 { ProjectScoreServiceAsyncImpl(clientOptions) }
private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptions) }

private val projectTag: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptions) }
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 { OrganizationServiceAsyncImpl(clientOptions) }
private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptions) }

private val apiKey: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) }
private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(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 apiKey(): ApiKeyServiceAsync = apiKey
override fun apiKeys(): ApiKeyServiceAsync = apiKeys
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,63 +32,63 @@ class BraintrustClientImpl constructor(private val clientOptions: ClientOptions,

private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptions) }

private val project: ProjectService by lazy { ProjectServiceImpl(clientOptions) }
private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptions) }

private val experiment: ExperimentService by lazy { ExperimentServiceImpl(clientOptions) }
private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptions) }

private val dataset: DatasetService by lazy { DatasetServiceImpl(clientOptions) }
private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptions) }

private val prompt: PromptService by lazy { PromptServiceImpl(clientOptions) }
private val prompts: PromptService by lazy { PromptServiceImpl(clientOptions) }

private val role: RoleService by lazy { RoleServiceImpl(clientOptions) }
private val roles: RoleService by lazy { RoleServiceImpl(clientOptions) }

private val group: GroupService by lazy { GroupServiceImpl(clientOptions) }
private val groups: GroupService by lazy { GroupServiceImpl(clientOptions) }

private val acl: AclService by lazy { AclServiceImpl(clientOptions) }
private val acls: AclService by lazy { AclServiceImpl(clientOptions) }

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

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

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

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

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

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

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

override fun async(): BraintrustClientAsync = async

override fun topLevel(): TopLevelService = topLevel

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

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

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

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

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

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

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

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

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

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

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

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

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

override fun apiKey(): ApiKeyService = apiKey
override fun apiKeys(): ApiKeyService = apiKeys
}
Loading

0 comments on commit a4b898c

Please sign in to comment.