Skip to content

Commit e12e57c

Browse files
SDK regeneration
1 parent 01f7891 commit e12e57c

39 files changed

+974
-574
lines changed

.fern/metadata.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"cliVersion": "3.29.1",
3+
"generatorName": "fernapi/fern-java-sdk",
4+
"generatorVersion": "3.27.4",
5+
"generatorConfig": {
6+
"publish-to": "central",
7+
"client-class-name": "BaseClient",
8+
"custom-dependencies": [
9+
"api org.apache.commons:commons-text:1.13.1"
10+
]
11+
},
12+
"sdkVersion": "1.1.6"
13+
}

README.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The Pipedream Java library provides convenient access to the Pipedream APIs from
1717
- [Retries](#retries)
1818
- [Timeouts](#timeouts)
1919
- [Custom Headers](#custom-headers)
20+
- [Access Raw Response Data](#access-raw-response-data)
2021
- [Contributing](#contributing)
2122
- [Reference](#reference)
2223

@@ -40,7 +41,7 @@ Add the dependency in your `pom.xml` file:
4041
<dependency>
4142
<groupId>com.pipedream</groupId>
4243
<artifactId>pipedream</artifactId>
43-
<version>1.1.5</version>
44+
<version>1.1.6</version>
4445
</dependency>
4546
```
4647

@@ -56,12 +57,10 @@ import com.pipedream.api.resources.actions.requests.RunActionOpts;
5657

5758
public class Example {
5859
public static void main(String[] args) {
59-
BaseClient client = BaseClient
60-
.builder()
61-
.clientId("<clientId>")
62-
.clientSecret("<clientSecret>")
60+
BaseClient client = BaseClient.withCredentials("<clientId>", "<clientSecret>")
6361
.projectId("YOUR_PROJECT_ID")
64-
.build();
62+
.build()
63+
;
6564

6665
client.actions().run(
6766
RunActionOpts
@@ -73,6 +72,29 @@ public class Example {
7372
}
7473
}
7574
```
75+
## Authentication
76+
77+
This SDK supports two authentication methods:
78+
79+
### Option 1: Direct Bearer Token
80+
81+
If you already have a valid access token, you can use it directly:
82+
83+
```java
84+
BaseClient client = BaseClient.withToken("your-access-token")
85+
.url("https://api.example.com")
86+
.build();
87+
```
88+
89+
### Option 2: OAuth Client Credentials
90+
91+
The SDK can automatically handle token acquisition and refresh:
92+
93+
```java
94+
BaseClient client = BaseClient.withCredentials("client-id", "client-secret")
95+
.url("https://api.example.com")
96+
.build();
97+
```
7698

7799
## Environments
78100

@@ -138,7 +160,9 @@ BaseClient client = BaseClient
138160

139161
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
140162
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
141-
retry limit (default: 2).
163+
retry limit (default: 2). Before defaulting to exponential backoff, the SDK will first attempt to respect
164+
the `Retry-After` header (as either in seconds or as an HTTP date), and then the `X-RateLimit-Reset` header
165+
(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff.
142166

143167
A request is deemed retryable when any of the following HTTP status codes is returned:
144168

@@ -160,23 +184,22 @@ BaseClient client = BaseClient
160184
### Timeouts
161185

162186
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
163-
164187
```java
165188
import com.pipedream.api.BaseClient;
166189
import com.pipedream.api.core.RequestOptions;
167190

168191
// Client level
169192
BaseClient client = BaseClient
170193
.builder()
171-
.timeout(10)
194+
.timeout(60)
172195
.build();
173196

174197
// Request level
175198
client.actions().run(
176199
...,
177200
RequestOptions
178201
.builder()
179-
.timeout(10)
202+
.timeout(60)
180203
.build()
181204
);
182205
```
@@ -207,6 +230,19 @@ client.actions().run(
207230
);
208231
```
209232

233+
### Access Raw Response Data
234+
235+
The SDK provides access to raw response data, including headers, through the `withRawResponse()` method.
236+
The `withRawResponse()` method returns a raw client that wraps all responses with `body()` and `headers()` methods.
237+
(A normal client's `response` is identical to a raw client's `response.body()`.)
238+
239+
```java
240+
RunHttpResponse response = client.actions().withRawResponse().run(...);
241+
242+
System.out.println(response.body());
243+
System.out.println(response.headers().get("X-My-Header"));
244+
```
245+
210246
## Contributing
211247

212248
While we value open-source contributions to this SDK, this library is generated programmatically.

build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ repositories {
1414
}
1515

1616
dependencies {
17-
api 'com.squareup.okhttp3:okhttp:4.12.0'
18-
api 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
19-
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2'
20-
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2'
17+
api 'com.squareup.okhttp3:okhttp:5.2.1'
18+
api 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
19+
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
20+
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
2121
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
2222
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2323
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
2424
api 'org.apache.commons:commons-text:1.13.1'
25-
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
2625
}
2726

2827

@@ -49,7 +48,7 @@ java {
4948

5049
group = 'com.pipedream'
5150

52-
version = '1.1.5'
51+
version = '1.1.6'
5352

5453
jar {
5554
dependsOn(":generatePomFileForMavenPublication")
@@ -80,7 +79,7 @@ publishing {
8079
maven(MavenPublication) {
8180
groupId = 'com.pipedream'
8281
artifactId = 'pipedream'
83-
version = '1.1.5'
82+
version = '1.1.6'
8483
from components.java
8584
pom {
8685
name = 'pipedream'

src/main/java/com/pipedream/api/AsyncBaseClient.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,22 @@ public AsyncOauthTokensClient oauthTokens() {
118118
return this.oauthTokensClient.get();
119119
}
120120

121-
public static AsyncBaseClientBuilder builder() {
122-
return new AsyncBaseClientBuilder();
121+
/**
122+
* Creates a client builder using a pre-generated access token.
123+
* @param token The access token to use for authentication
124+
* @return A builder configured for token authentication
125+
*/
126+
public static AsyncBaseClientBuilder._TokenAuth withToken(String token) {
127+
return AsyncBaseClientBuilder.withToken(token);
128+
}
129+
130+
/**
131+
* Creates a client builder using OAuth client credentials.
132+
* @param clientId The OAuth client ID
133+
* @param clientSecret The OAuth client secret
134+
* @return A builder configured for OAuth authentication
135+
*/
136+
public static AsyncBaseClientBuilder._CredentialsAuth withCredentials(String clientId, String clientSecret) {
137+
return AsyncBaseClientBuilder.withCredentials(clientId, clientSecret);
123138
}
124139
}

src/main/java/com/pipedream/api/BaseClient.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,22 @@ public OauthTokensClient oauthTokens() {
118118
return this.oauthTokensClient.get();
119119
}
120120

121-
public static BaseClientBuilder builder() {
122-
return new BaseClientBuilder();
121+
/**
122+
* Creates a client builder using a pre-generated access token.
123+
* @param token The access token to use for authentication
124+
* @return A builder configured for token authentication
125+
*/
126+
public static BaseClientBuilder._TokenAuth withToken(String token) {
127+
return BaseClientBuilder.withToken(token);
128+
}
129+
130+
/**
131+
* Creates a client builder using OAuth client credentials.
132+
* @param clientId The OAuth client ID
133+
* @param clientSecret The OAuth client secret
134+
* @return A builder configured for OAuth authentication
135+
*/
136+
public static BaseClientBuilder._CredentialsAuth withCredentials(String clientId, String clientSecret) {
137+
return BaseClientBuilder.withCredentials(clientId, clientSecret);
123138
}
124139
}

src/main/java/com/pipedream/api/core/BaseClientApiException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public Map<String, List<String>> headers() {
6565
return this.headers;
6666
}
6767

68-
@java.lang.Override
68+
@Override
6969
public String toString() {
7070
return "BaseClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
71-
+ body + "}";
71+
+ ObjectMappers.stringify(body) + "}";
7272
}
7373
}

src/main/java/com/pipedream/api/core/ClientOptions.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public final class ClientOptions {
2121

2222
private final int timeout;
2323

24+
private final int maxRetries;
25+
2426
private String projectId;
2527

2628
private ClientOptions(
@@ -29,21 +31,23 @@ private ClientOptions(
2931
Map<String, Supplier<String>> headerSuppliers,
3032
OkHttpClient httpClient,
3133
int timeout,
34+
int maxRetries,
3235
String projectId) {
3336
this.environment = environment;
3437
this.headers = new HashMap<>();
3538
this.headers.putAll(headers);
3639
this.headers.putAll(new HashMap<String, String>() {
3740
{
38-
put("User-Agent", "com.pipedream:pipedream/1.1.5");
41+
put("User-Agent", "com.pipedream:pipedream/1.1.6");
3942
put("X-Fern-Language", "JAVA");
4043
put("X-Fern-SDK-Name", "com.pipedream.fern:api-sdk");
41-
put("X-Fern-SDK-Version", "1.1.5");
44+
put("X-Fern-SDK-Version", "1.1.6");
4245
}
4346
});
4447
this.headerSuppliers = headerSuppliers;
4548
this.httpClient = httpClient;
4649
this.timeout = timeout;
50+
this.maxRetries = maxRetries;
4751
this.projectId = projectId;
4852
}
4953

@@ -86,6 +90,10 @@ public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) {
8690
.build();
8791
}
8892

93+
public int maxRetries() {
94+
return this.maxRetries;
95+
}
96+
8997
public String projectId() {
9098
return this.projectId;
9199
}
@@ -181,7 +189,13 @@ public ClientOptions build() {
181189
this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000);
182190

183191
return new ClientOptions(
184-
environment, headers, headerSuppliers, httpClient, this.timeout.get(), this.projectId);
192+
environment,
193+
headers,
194+
headerSuppliers,
195+
httpClient,
196+
this.timeout.get(),
197+
this.maxRetries,
198+
this.projectId);
185199
}
186200

187201
/**
@@ -192,6 +206,9 @@ public static Builder from(ClientOptions clientOptions) {
192206
builder.environment = clientOptions.environment();
193207
builder.timeout = Optional.of(clientOptions.timeout(null));
194208
builder.httpClient = clientOptions.httpClient();
209+
builder.headers.putAll(clientOptions.headers);
210+
builder.headerSuppliers.putAll(clientOptions.headerSuppliers);
211+
builder.maxRetries = clientOptions.maxRetries();
195212
builder.projectId = clientOptions.projectId();
196213
return builder;
197214
}

src/main/java/com/pipedream/api/core/NullableNonemptyFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public boolean equals(Object o) {
1414
}
1515

1616
private boolean isOptionalEmpty(Object o) {
17-
return o instanceof Optional && !((Optional<?>) o).isPresent();
17+
if (o instanceof Optional) {
18+
return !((Optional<?>) o).isPresent();
19+
}
20+
return false;
1821
}
1922
}

src/main/java/com/pipedream/api/core/OAuthTokenSupplier.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ public final class OAuthTokenSupplier implements Supplier<String> {
1717

1818
private final String clientSecret;
1919

20+
private final String scope;
21+
2022
private final OauthTokensClient authClient;
2123

2224
private String accessToken;
2325

2426
private Instant expiresAt;
2527

26-
public OAuthTokenSupplier(String clientId, String clientSecret, OauthTokensClient authClient) {
28+
public OAuthTokenSupplier(String clientId, String clientSecret, String scope, OauthTokensClient authClient) {
2729
this.clientId = clientId;
2830
this.clientSecret = clientSecret;
31+
this.scope = scope;
2932
this.authClient = authClient;
3033
this.expiresAt = Instant.now();
3134
}
@@ -34,6 +37,7 @@ public CreateOAuthTokenResponse fetchToken() {
3437
CreateOAuthTokenOpts getTokenRequest = CreateOAuthTokenOpts.builder()
3538
.clientId(clientId)
3639
.clientSecret(clientSecret)
40+
.scope(scope)
3741
.build();
3842
return authClient.create(getTokenRequest);
3943
}

src/main/java/com/pipedream/api/core/ObjectMappers.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.pipedream.api.core;
55

66
import com.fasterxml.jackson.annotation.JsonInclude;
7+
import com.fasterxml.jackson.core.JsonProcessingException;
78
import com.fasterxml.jackson.databind.DeserializationFeature;
89
import com.fasterxml.jackson.databind.ObjectMapper;
910
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -33,4 +34,12 @@ public static String stringify(Object o) {
3334
return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode());
3435
}
3536
}
37+
38+
public static Object parseErrorBody(String responseBodyString) {
39+
try {
40+
return JSON_MAPPER.readValue(responseBodyString, Object.class);
41+
} catch (JsonProcessingException ignored) {
42+
return responseBodyString;
43+
}
44+
}
3645
}

0 commit comments

Comments
 (0)