Skip to content
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Add the dependency in your `pom.xml` file:
<dependency>
<groupId>com.pipedream</groupId>
<artifactId>pipedream</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ java {

group = 'com.pipedream'

version = '1.0.4'
version = '1.0.5'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -79,7 +79,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.pipedream'
artifactId = 'pipedream'
version = '1.0.4'
version = '1.0.5'
from components.java
pom {
name = 'pipedream'
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/pipedream/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ private ClientOptions(
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String, String>() {
{
put("User-Agent", "com.pipedream:pipedream/1.0.4");
put("User-Agent", "com.pipedream:pipedream/1.0.5");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.pipedream.fern:api-sdk");
put("X-Fern-SDK-Version", "1.0.4");
put("X-Fern-SDK-Version", "1.0.5");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.pipedream.api.resources.filestash;

import com.pipedream.api.core.ClientOptions;
import com.pipedream.api.core.RequestOptions;
import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest;
import java.util.concurrent.CompletableFuture;

public class AsyncFileStashClient {
protected final ClientOptions clientOptions;

private final AsyncRawFileStashClient rawClient;

public AsyncFileStashClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawFileStashClient(clientOptions);
}

/**
* Get responses with HTTP metadata like headers
*/
public AsyncRawFileStashClient withRawResponse() {
return this.rawClient;
}

/**
* Download a file from File Stash
*/
public CompletableFuture<Void> downloadFile(FileStashDownloadFileRequest request) {
return this.rawClient.downloadFile(request).thenApply(response -> response.body());
}

/**
* Download a file from File Stash
*/
public CompletableFuture<Void> downloadFile(FileStashDownloadFileRequest request, RequestOptions requestOptions) {
return this.rawClient.downloadFile(request, requestOptions).thenApply(response -> response.body());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.pipedream.api.resources.filestash;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.pipedream.api.core.BaseClientApiException;
import com.pipedream.api.core.BaseClientException;
import com.pipedream.api.core.BaseClientHttpResponse;
import com.pipedream.api.core.ClientOptions;
import com.pipedream.api.core.ObjectMappers;
import com.pipedream.api.core.QueryStringMapper;
import com.pipedream.api.core.RequestOptions;
import com.pipedream.api.errors.TooManyRequestsError;
import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;

public class AsyncRawFileStashClient {
protected final ClientOptions clientOptions;

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

/**
* Download a file from File Stash
*/
public CompletableFuture<BaseClientHttpResponse<Void>> downloadFile(FileStashDownloadFileRequest request) {
return downloadFile(request, null);
}

/**
* Download a file from File Stash
*/
public CompletableFuture<BaseClientHttpResponse<Void>> downloadFile(
FileStashDownloadFileRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
.addPathSegments("file_stash/download");
QueryStringMapper.addQueryParameter(httpUrl, "s3_key", request.getS3Key(), false);
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
CompletableFuture<BaseClientHttpResponse<Void>> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (response.isSuccessful()) {
future.complete(new BaseClientHttpResponse<>(null, response));
return;
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
future.completeExceptionally(new TooManyRequestsError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response));
return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
future.completeExceptionally(new BaseClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
} catch (IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
}
}

@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e));
}
});
return future;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.pipedream.api.resources.filestash;

import com.pipedream.api.core.ClientOptions;
import com.pipedream.api.core.RequestOptions;
import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest;

public class FileStashClient {
protected final ClientOptions clientOptions;

private final RawFileStashClient rawClient;

public FileStashClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawFileStashClient(clientOptions);
}

/**
* Get responses with HTTP metadata like headers
*/
public RawFileStashClient withRawResponse() {
return this.rawClient;
}

/**
* Download a file from File Stash
*/
public void downloadFile(FileStashDownloadFileRequest request) {
this.rawClient.downloadFile(request).body();
}

/**
* Download a file from File Stash
*/
public void downloadFile(FileStashDownloadFileRequest request, RequestOptions requestOptions) {
this.rawClient.downloadFile(request, requestOptions).body();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.pipedream.api.resources.filestash;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.pipedream.api.core.BaseClientApiException;
import com.pipedream.api.core.BaseClientException;
import com.pipedream.api.core.BaseClientHttpResponse;
import com.pipedream.api.core.ClientOptions;
import com.pipedream.api.core.ObjectMappers;
import com.pipedream.api.core.QueryStringMapper;
import com.pipedream.api.core.RequestOptions;
import com.pipedream.api.errors.TooManyRequestsError;
import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

public class RawFileStashClient {
protected final ClientOptions clientOptions;

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

/**
* Download a file from File Stash
*/
public BaseClientHttpResponse<Void> downloadFile(FileStashDownloadFileRequest request) {
return downloadFile(request, null);
}

/**
* Download a file from File Stash
*/
public BaseClientHttpResponse<Void> downloadFile(
FileStashDownloadFileRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("v1/connect")
.addPathSegment(clientOptions.projectId())
.addPathSegments("file_stash/download");
QueryStringMapper.addQueryParameter(httpUrl, "s3_key", request.getS3Key(), false);
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("GET", null)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Accept", "application/json");
Request okhttpRequest = _requestBuilder.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
try (Response response = client.newCall(okhttpRequest).execute()) {
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
return new BaseClientHttpResponse<>(null, response);
}
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
if (response.code() == 429) {
throw new TooManyRequestsError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
}
throw new BaseClientApiException(
"Error with status code " + response.code(),
response.code(),
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response);
} catch (IOException e) {
throw new BaseClientException("Network error executing HTTP request", e);
}
}
}
Loading