Skip to content

Commit c3130cd

Browse files
fern-api[bot]jverceverhovskyJacob Pines
authored
Changes in component operations (#164)
* Regenerate SDK with Fern's v3 Java generator * Run actions using a specific component version * Expose component key when retrieving deployed triggers * Associate workflow ID when deploying triggers * Filter component lists by emitter type (e.g. HTTP, Timer, etc.) * Replace type of component listing and retrieval with the new `Emitter` type --------- Co-authored-by: Jay Vercellone <jay@pipedream.com> Co-authored-by: Boris Verkhovskiy <boris@pipedream.com> Co-authored-by: Jacob Pines <jacob@pipedream.com>
1 parent caa554c commit c3130cd

File tree

107 files changed

+5136
-812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+5136
-812
lines changed

.fernignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,25 @@ LICENSE
1010
reference.md
1111

1212
# Base client files (temporary)
13+
src/main/java/com/pipedream/api/AsyncBaseClientBuilder.java
14+
src/main/java/com/pipedream/api/BaseClientBuilder.java
1315

1416
# Custom Pipedream client files
17+
src/main/java/com/pipedream/api/AsyncPipedreamClient.java
18+
src/main/java/com/pipedream/api/AsyncPipedreamClientBuilder.java
19+
src/main/java/com/pipedream/api/PipedreamClient.java
20+
src/main/java/com/pipedream/api/PipedreamClientBuilder.java
1521

1622
# Custom Proxy files
23+
src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java
24+
src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java
1725

1826
# Custom Workflow files
27+
src/main/java/com/pipedream/api/resources/workflows/AsyncWorkflowsClient.java
28+
src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java
29+
src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java
30+
src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java
31+
src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java
32+
src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java
33+
src/main/java/com/pipedream/api/resources/workflows/package-info.java
34+
src/main/java/com/pipedream/api/types/HTTPAuthType.java

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Add the dependency in your `pom.xml` file:
2525
<dependency>
2626
<groupId>com.pipedream</groupId>
2727
<artifactId>pipedream</artifactId>
28-
<version>1.0.5</version>
28+
<version>1.0.6</version>
2929
</dependency>
3030
```
3131

@@ -45,10 +45,10 @@ public class Example {
4545
.builder()
4646
.clientId("<clientId>")
4747
.clientSecret("<clientSecret>")
48+
.projectId("YOUR_PROJECT_ID")
4849
.build();
4950

5051
client.actions().run(
51-
"project_id",
5252
RunActionOpts
5353
.builder()
5454
.id("id")
@@ -93,9 +93,9 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc
9393
```java
9494
import com.pipedream.api.core.PipedreamApiApiException;
9595

96-
try {
96+
try{
9797
client.actions().run(...);
98-
} catch (PipedreamApiApiException e) {
98+
} catch (PipedreamApiApiException e){
9999
// Do something with the API exception...
100100
}
101101
```

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies {
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'
2526
}
2627

2728

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

4950
group = 'com.pipedream'
5051

51-
version = '1.0.5'
52+
version = '1.0.6'
5253

5354
jar {
5455
dependsOn(":generatePomFileForMavenPublication")
@@ -79,7 +80,7 @@ publishing {
7980
maven(MavenPublication) {
8081
groupId = 'com.pipedream'
8182
artifactId = 'pipedream'
82-
version = '1.0.5'
83+
version = '1.0.6'
8384
from components.java
8485
pom {
8586
name = 'pipedream'

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.pipedream.api.resources.apps.AsyncAppsClient;
1212
import com.pipedream.api.resources.components.AsyncComponentsClient;
1313
import com.pipedream.api.resources.deployedtriggers.AsyncDeployedTriggersClient;
14+
import com.pipedream.api.resources.filestash.AsyncFileStashClient;
1415
import com.pipedream.api.resources.oauthtokens.AsyncOauthTokensClient;
1516
import com.pipedream.api.resources.projects.AsyncProjectsClient;
1617
import com.pipedream.api.resources.proxy.AsyncProxyClient;
@@ -40,6 +41,8 @@ public class AsyncBaseClient {
4041

4142
protected final Supplier<AsyncProjectsClient> projectsClient;
4243

44+
protected final Supplier<AsyncFileStashClient> fileStashClient;
45+
4346
protected final Supplier<AsyncProxyClient> proxyClient;
4447

4548
protected final Supplier<AsyncTokensClient> tokensClient;
@@ -57,6 +60,7 @@ public AsyncBaseClient(ClientOptions clientOptions) {
5760
this.triggersClient = Suppliers.memoize(() -> new AsyncTriggersClient(clientOptions));
5861
this.deployedTriggersClient = Suppliers.memoize(() -> new AsyncDeployedTriggersClient(clientOptions));
5962
this.projectsClient = Suppliers.memoize(() -> new AsyncProjectsClient(clientOptions));
63+
this.fileStashClient = Suppliers.memoize(() -> new AsyncFileStashClient(clientOptions));
6064
this.proxyClient = Suppliers.memoize(() -> new AsyncProxyClient(clientOptions));
6165
this.tokensClient = Suppliers.memoize(() -> new AsyncTokensClient(clientOptions));
6266
this.oauthTokensClient = Suppliers.memoize(() -> new AsyncOauthTokensClient(clientOptions));
@@ -98,6 +102,10 @@ public AsyncProjectsClient projects() {
98102
return this.projectsClient.get();
99103
}
100104

105+
public AsyncFileStashClient fileStash() {
106+
return this.fileStashClient.get();
107+
}
108+
101109
public AsyncProxyClient proxy() {
102110
return this.proxyClient.get();
103111
}

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

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.pipedream.api.core.Environment;
88
import com.pipedream.api.core.OAuthTokenSupplier;
99
import com.pipedream.api.resources.oauthtokens.OauthTokensClient;
10+
import java.util.HashMap;
11+
import java.util.Map;
1012
import java.util.Optional;
1113
import okhttp3.OkHttpClient;
1214

@@ -15,6 +17,8 @@ public class AsyncBaseClientBuilder<T extends AsyncBaseClientBuilder<T>> {
1517

1618
private Optional<Integer> maxRetries = Optional.empty();
1719

20+
private final Map<String, String> customHeaders = new HashMap<>();
21+
1822
private String clientId = System.getenv("PIPEDREAM_CLIENT_ID");
1923

2024
private String clientSecret = System.getenv("PIPEDREAM_CLIENT_SECRET");
@@ -25,6 +29,8 @@ public class AsyncBaseClientBuilder<T extends AsyncBaseClientBuilder<T>> {
2529

2630
private OkHttpClient httpClient;
2731

32+
private String projectId;
33+
2834
/**
2935
* Sets clientId.
3036
* Defaults to the PIPEDREAM_CLIENT_ID environment variable.
@@ -93,6 +99,26 @@ public T httpClient(OkHttpClient httpClient) {
9399
return (T) this;
94100
}
95101

102+
/**
103+
* Add a custom header to be sent with all requests.
104+
* For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
105+
*
106+
* @param name The header name
107+
* @param value The header value
108+
* @return This builder for method chaining
109+
*/
110+
@SuppressWarnings("unchecked")
111+
public T addHeader(String name, String value) {
112+
this.customHeaders.put(name, value);
113+
return (T) this;
114+
}
115+
116+
@SuppressWarnings("unchecked")
117+
public T projectId(String projectId) {
118+
this.projectId = projectId;
119+
return (T) this;
120+
}
121+
96122
protected ClientOptions buildClientOptions() {
97123
ClientOptions.Builder builder = ClientOptions.builder();
98124
setEnvironment(builder);
@@ -102,6 +128,9 @@ protected ClientOptions buildClientOptions() {
102128
setHttpClient(builder);
103129
setTimeouts(builder);
104130
setRetries(builder);
131+
for (Map.Entry<String, String> header : this.customHeaders.entrySet()) {
132+
builder.addHeader(header.getKey(), header.getValue());
133+
}
105134
setAdditional(builder);
106135
return builder.build();
107136
}
@@ -124,7 +153,7 @@ protected void setEnvironment(ClientOptions.Builder builder) {
124153
*
125154
* Example:
126155
* <pre>{@code
127-
* @Override
156+
* &#64;Override
128157
* protected void setAuthentication(ClientOptions.Builder builder) {
129158
* super.setAuthentication(builder); // Keep existing auth
130159
* builder.addHeader("X-API-Key", this.apiKey);
@@ -133,8 +162,12 @@ protected void setEnvironment(ClientOptions.Builder builder) {
133162
*/
134163
protected void setAuthentication(ClientOptions.Builder builder) {
135164
if (this.clientId != null && this.clientSecret != null) {
136-
OauthTokensClient authClient = new OauthTokensClient(
137-
ClientOptions.builder().environment(this.environment).build());
165+
ClientOptions.Builder authClientOptionsBuilder =
166+
ClientOptions.builder().environment(this.environment);
167+
if (this.projectId != null) {
168+
authClientOptionsBuilder.projectId(this.projectId);
169+
}
170+
OauthTokensClient authClient = new OauthTokensClient(authClientOptionsBuilder.build());
138171
OAuthTokenSupplier oAuthTokenSupplier =
139172
new OAuthTokenSupplier(this.clientId, this.clientSecret, authClient);
140173
builder.addHeader("Authorization", oAuthTokenSupplier);
@@ -149,7 +182,7 @@ protected void setAuthentication(ClientOptions.Builder builder) {
149182
*
150183
* Example:
151184
* <pre>{@code
152-
* @Override
185+
* &#64;Override
153186
* protected void setCustomHeaders(ClientOptions.Builder builder) {
154187
* super.setCustomHeaders(builder); // Keep existing headers
155188
* builder.addHeader("X-Trace-ID", generateTraceId());
@@ -168,7 +201,11 @@ protected void setCustomHeaders(ClientOptions.Builder builder) {
168201
*
169202
* @param builder The ClientOptions.Builder to configure
170203
*/
171-
protected void setVariables(ClientOptions.Builder builder) {}
204+
protected void setVariables(ClientOptions.Builder builder) {
205+
if (this.projectId != null) {
206+
builder.projectId(this.projectId);
207+
}
208+
}
172209

173210
/**
174211
* Sets the request timeout configuration.
@@ -215,9 +252,9 @@ protected void setHttpClient(ClientOptions.Builder builder) {
215252
*
216253
* Example:
217254
* <pre>{@code
218-
* @Override
255+
* &#64;Override
219256
* protected void setAdditional(ClientOptions.Builder builder) {
220-
* builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
257+
* builder.addHeader("X-Request-ID", () -&gt; UUID.randomUUID().toString());
221258
* builder.addHeader("X-Client-Version", "1.0.0");
222259
* }
223260
* }</pre>
@@ -231,7 +268,7 @@ protected void setAdditional(ClientOptions.Builder builder) {}
231268
*
232269
* Example:
233270
* <pre>{@code
234-
* @Override
271+
* &#64;Override
235272
* protected void validateConfiguration() {
236273
* super.validateConfiguration(); // Run parent validations
237274
* if (tenantId == null || tenantId.isEmpty()) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.pipedream.api.resources.apps.AppsClient;
1212
import com.pipedream.api.resources.components.ComponentsClient;
1313
import com.pipedream.api.resources.deployedtriggers.DeployedTriggersClient;
14+
import com.pipedream.api.resources.filestash.FileStashClient;
1415
import com.pipedream.api.resources.oauthtokens.OauthTokensClient;
1516
import com.pipedream.api.resources.projects.ProjectsClient;
1617
import com.pipedream.api.resources.proxy.ProxyClient;
@@ -40,6 +41,8 @@ public class BaseClient {
4041

4142
protected final Supplier<ProjectsClient> projectsClient;
4243

44+
protected final Supplier<FileStashClient> fileStashClient;
45+
4346
protected final Supplier<ProxyClient> proxyClient;
4447

4548
protected final Supplier<TokensClient> tokensClient;
@@ -57,6 +60,7 @@ public BaseClient(ClientOptions clientOptions) {
5760
this.triggersClient = Suppliers.memoize(() -> new TriggersClient(clientOptions));
5861
this.deployedTriggersClient = Suppliers.memoize(() -> new DeployedTriggersClient(clientOptions));
5962
this.projectsClient = Suppliers.memoize(() -> new ProjectsClient(clientOptions));
63+
this.fileStashClient = Suppliers.memoize(() -> new FileStashClient(clientOptions));
6064
this.proxyClient = Suppliers.memoize(() -> new ProxyClient(clientOptions));
6165
this.tokensClient = Suppliers.memoize(() -> new TokensClient(clientOptions));
6266
this.oauthTokensClient = Suppliers.memoize(() -> new OauthTokensClient(clientOptions));
@@ -98,6 +102,10 @@ public ProjectsClient projects() {
98102
return this.projectsClient.get();
99103
}
100104

105+
public FileStashClient fileStash() {
106+
return this.fileStashClient.get();
107+
}
108+
101109
public ProxyClient proxy() {
102110
return this.proxyClient.get();
103111
}

0 commit comments

Comments
 (0)