Skip to content

Commit

Permalink
Release 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jan 23, 2024
1 parent 8d9dc4a commit 5ed607a
Show file tree
Hide file tree
Showing 71 changed files with 7,541 additions and 65 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.flatfile'
artifactId = 'flatfile-java'
version = '0.0.4'
version = '0.0.5'
from components.java
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/flatfile/api/Flatfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import com.flatfile.api.core.ClientOptions;
import com.flatfile.api.core.Suppliers;
import com.flatfile.api.resources.agents.AgentsClient;
import com.flatfile.api.resources.apps.AppsClient;
import com.flatfile.api.resources.commits.CommitsClient;
import com.flatfile.api.resources.dataretentionpolicies.DataRetentionPoliciesClient;
import com.flatfile.api.resources.documents.DocumentsClient;
import com.flatfile.api.resources.environments.EnvironmentsClient;
import com.flatfile.api.resources.events.EventsClient;
import com.flatfile.api.resources.files.FilesClient;
import com.flatfile.api.resources.guests.GuestsClient;
import com.flatfile.api.resources.jobs.JobsClient;
import com.flatfile.api.resources.mapping.MappingClient;
import com.flatfile.api.resources.records.RecordsClient;
import com.flatfile.api.resources.roles.RolesClient;
import com.flatfile.api.resources.secrets.SecretsClient;
Expand All @@ -29,8 +32,12 @@ public class Flatfile {

protected final Supplier<AgentsClient> agentsClient;

protected final Supplier<AppsClient> appsClient;

protected final Supplier<CommitsClient> commitsClient;

protected final Supplier<DataRetentionPoliciesClient> dataRetentionPoliciesClient;

protected final Supplier<DocumentsClient> documentsClient;

protected final Supplier<EnvironmentsClient> environmentsClient;
Expand All @@ -43,6 +50,8 @@ public class Flatfile {

protected final Supplier<JobsClient> jobsClient;

protected final Supplier<MappingClient> mappingClient;

protected final Supplier<RecordsClient> recordsClient;

protected final Supplier<RolesClient> rolesClient;
Expand All @@ -64,13 +73,16 @@ public class Flatfile {
public Flatfile(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.agentsClient = Suppliers.memoize(() -> new AgentsClient(clientOptions));
this.appsClient = Suppliers.memoize(() -> new AppsClient(clientOptions));
this.commitsClient = Suppliers.memoize(() -> new CommitsClient(clientOptions));
this.dataRetentionPoliciesClient = Suppliers.memoize(() -> new DataRetentionPoliciesClient(clientOptions));
this.documentsClient = Suppliers.memoize(() -> new DocumentsClient(clientOptions));
this.environmentsClient = Suppliers.memoize(() -> new EnvironmentsClient(clientOptions));
this.eventsClient = Suppliers.memoize(() -> new EventsClient(clientOptions));
this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions));
this.guestsClient = Suppliers.memoize(() -> new GuestsClient(clientOptions));
this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions));
this.mappingClient = Suppliers.memoize(() -> new MappingClient(clientOptions));
this.recordsClient = Suppliers.memoize(() -> new RecordsClient(clientOptions));
this.rolesClient = Suppliers.memoize(() -> new RolesClient(clientOptions));
this.secretsClient = Suppliers.memoize(() -> new SecretsClient(clientOptions));
Expand All @@ -86,10 +98,18 @@ public AgentsClient agents() {
return this.agentsClient.get();
}

public AppsClient apps() {
return this.appsClient.get();
}

public CommitsClient commits() {
return this.commitsClient.get();
}

public DataRetentionPoliciesClient dataRetentionPolicies() {
return this.dataRetentionPoliciesClient.get();
}

public DocumentsClient documents() {
return this.documentsClient.get();
}
Expand All @@ -114,6 +134,10 @@ public JobsClient jobs() {
return this.jobsClient.get();
}

public MappingClient mapping() {
return this.mappingClient.get();
}

public RecordsClient records() {
return this.recordsClient.get();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/flatfile/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private ClientOptions(
"X-Fern-SDK-Name",
"com.flatfile.fern:api-sdk",
"X-Fern-SDK-Version",
"0.0.4",
"0.0.5",
"X-Fern-Language",
"JAVA"));
this.headerSuppliers = headerSuppliers;
Expand Down
192 changes: 192 additions & 0 deletions src/main/java/com/flatfile/api/resources/apps/AppsClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.flatfile.api.resources.apps;

import com.flatfile.api.core.ApiError;
import com.flatfile.api.core.ClientOptions;
import com.flatfile.api.core.ObjectMappers;
import com.flatfile.api.core.RequestOptions;
import com.flatfile.api.resources.apps.types.AppCreate;
import com.flatfile.api.resources.apps.types.AppPatch;
import com.flatfile.api.resources.apps.types.AppResponse;
import com.flatfile.api.resources.apps.types.AppsResponse;
import com.flatfile.api.resources.commons.types.AppId;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class AppsClient {
protected final ClientOptions clientOptions;

public AppsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}

/**
* Returns apps in an account
*/
public AppsResponse list(RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("apps")
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.build();
try {
Response response =
clientOptions.httpClient().newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), AppsResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Returns apps in an account
*/
public AppsResponse list() {
return list(null);
}

/**
* Returns an app
*/
public AppResponse get(AppId appId, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("apps")
.addPathSegment(appId.toString())
.build();
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.build();
try {
Response response =
clientOptions.httpClient().newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), AppResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Returns an app
*/
public AppResponse get(AppId appId) {
return get(appId, null);
}

/**
* Updates an app
*/
public AppResponse update(AppId appId) {
return update(appId, AppPatch.builder().build());
}

/**
* Updates an app
*/
public AppResponse update(AppId appId, AppPatch request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("apps")
.addPathSegment(appId.toString())
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json"));
} catch (Exception e) {
throw new RuntimeException(e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("PATCH", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.build();
try {
Response response =
clientOptions.httpClient().newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), AppResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Updates an app
*/
public AppResponse update(AppId appId, AppPatch request) {
return update(appId, request, null);
}

/**
* Creates an app
*/
public AppResponse create(AppCreate request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("apps")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaType.parse("application/json"));
} catch (Exception e) {
throw new RuntimeException(e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.build();
try {
Response response =
clientOptions.httpClient().newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), AppResponse.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Creates an app
*/
public AppResponse create(AppCreate request) {
return create(request, null);
}
}
Loading

0 comments on commit 5ed607a

Please sign in to comment.