Skip to content

Commit 20b2672

Browse files
committed
Add support for workflow invocations
* Add `workflows` package that contains the "invoke" and "invoke for external user" cases already present in the existing SDKs * Document the new functionality in the reference doc
1 parent a1e5654 commit 20b2672

16 files changed

+1401
-24
lines changed

.fernignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ src/main/java/com/pipedream/api/PipedreamClient.java
1111
src/main/java/com/pipedream/api/PipedreamClientBuilder.java
1212
src/main/java/com/pipedream/api/AsyncPipedreamClient.java
1313
src/main/java/com/pipedream/api/AsyncPipedreamClientBuilder.java
14+
src/main/java/com/pipedream/api/resources/workflows/*
15+
src/main/java/com/pipedream/api/types/HTTPAuthType.java

reference.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,205 @@ client.tokens().validate(
28332833
</dl>
28342834

28352835

2836+
</dd>
2837+
</dl>
2838+
</details>
2839+
2840+
## Workflows
2841+
<details><summary><code>client.workflows.invoke(urlOrEndpoint) -> Object</code></summary>
2842+
<dl>
2843+
<dd>
2844+
2845+
#### 🔌 Usage
2846+
2847+
<dl>
2848+
<dd>
2849+
2850+
<dl>
2851+
<dd>
2852+
2853+
```java
2854+
// Simple workflow invocation (uses OAuth authentication by default)
2855+
client.workflows().invoke("eo3xxxx");
2856+
2857+
// Advanced workflow invocation with all options
2858+
client.workflows().invoke(
2859+
InvokeWorkflowOpts
2860+
.builder()
2861+
.urlOrEndpoint("https://eo3xxxx.m.pipedream.net")
2862+
.body(
2863+
new HashMap<String, Object>() {{
2864+
put("name", "John Doe");
2865+
put("email", "[email protected]");
2866+
}}
2867+
)
2868+
.headers(
2869+
new HashMap<String, String>() {{
2870+
put("Content-Type", "application/json");
2871+
put("Authorization", "Bearer your-token"); // For STATIC_BEARER auth
2872+
}}
2873+
)
2874+
.method("POST")
2875+
.authType(HTTPAuthType.STATIC_BEARER)
2876+
.build()
2877+
);
2878+
```
2879+
</dd>
2880+
</dl>
2881+
</dd>
2882+
</dl>
2883+
2884+
#### ⚙️ Parameters
2885+
2886+
<dl>
2887+
<dd>
2888+
2889+
<dl>
2890+
<dd>
2891+
2892+
**urlOrEndpoint:** `String` — Either a workflow endpoint ID (e.g., 'eo3xxxx') or a full workflow URL
2893+
2894+
</dd>
2895+
</dl>
2896+
2897+
<dl>
2898+
<dd>
2899+
2900+
**body:** `Optional<Object>` — Request body to send to the workflow (will be JSON serialized)
2901+
2902+
</dd>
2903+
</dl>
2904+
2905+
<dl>
2906+
<dd>
2907+
2908+
**headers:** `Optional<Map<String, String>>` — Additional headers to include in the request
2909+
2910+
</dd>
2911+
</dl>
2912+
2913+
<dl>
2914+
<dd>
2915+
2916+
**method:** `Optional<String>` — HTTP method to use (defaults to 'POST')
2917+
2918+
</dd>
2919+
</dl>
2920+
2921+
<dl>
2922+
<dd>
2923+
2924+
**authType:** `Optional<HTTPAuthType>` — Authentication type: OAUTH (default), STATIC_BEARER, or NONE
2925+
2926+
</dd>
2927+
</dl>
2928+
</dd>
2929+
</dl>
2930+
2931+
2932+
</dd>
2933+
</dl>
2934+
</details>
2935+
2936+
<details><summary><code>client.workflows.invokeForExternalUser(urlOrEndpoint, externalUserId) -> Object</code></summary>
2937+
<dl>
2938+
<dd>
2939+
2940+
#### 🔌 Usage
2941+
2942+
<dl>
2943+
<dd>
2944+
2945+
<dl>
2946+
<dd>
2947+
2948+
```java
2949+
// Simple external user invocation (uses OAuth authentication by default)
2950+
client.workflows().invokeForExternalUser("eo3xxxx", "user123");
2951+
2952+
// Advanced external user invocation with all options
2953+
client.workflows().invokeForExternalUser(
2954+
InvokeWorkflowForExternalUserOpts
2955+
.builder()
2956+
.url("https://eo3xxxx.m.pipedream.net")
2957+
.externalUserId("user123")
2958+
.body(
2959+
new HashMap<String, Object>() {{
2960+
put("action", "process_data");
2961+
put("data", Arrays.asList("item1", "item2"));
2962+
}}
2963+
)
2964+
.headers(
2965+
new HashMap<String, String>() {{
2966+
put("X-Custom-Header", "value");
2967+
}}
2968+
)
2969+
.method("POST")
2970+
.authType(HTTPAuthType.OAUTH)
2971+
.build()
2972+
);
2973+
```
2974+
</dd>
2975+
</dl>
2976+
</dd>
2977+
</dl>
2978+
2979+
#### ⚙️ Parameters
2980+
2981+
<dl>
2982+
<dd>
2983+
2984+
<dl>
2985+
<dd>
2986+
2987+
**url:** `String` — The full workflow URL to invoke
2988+
2989+
</dd>
2990+
</dl>
2991+
2992+
<dl>
2993+
<dd>
2994+
2995+
**externalUserId:** `String` — The external user ID for Pipedream Connect authentication
2996+
2997+
</dd>
2998+
</dl>
2999+
3000+
<dl>
3001+
<dd>
3002+
3003+
**body:** `Optional<Object>` — Request body to send to the workflow (will be JSON serialized)
3004+
3005+
</dd>
3006+
</dl>
3007+
3008+
<dl>
3009+
<dd>
3010+
3011+
**headers:** `Optional<Map<String, String>>` — Additional headers to include in the request
3012+
3013+
</dd>
3014+
</dl>
3015+
3016+
<dl>
3017+
<dd>
3018+
3019+
**method:** `Optional<String>` — HTTP method to use (defaults to 'POST')
3020+
3021+
</dd>
3022+
</dl>
3023+
3024+
<dl>
3025+
<dd>
3026+
3027+
**authType:** `Optional<HTTPAuthType>` — Authentication type: OAUTH (default), STATIC_BEARER, or NONE
3028+
3029+
</dd>
3030+
</dl>
3031+
</dd>
3032+
</dl>
3033+
3034+
28363035
</dd>
28373036
</dl>
28383037
</details>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.pipedream.api.resources.tokens.AsyncTokensClient;
1818
import com.pipedream.api.resources.triggers.AsyncTriggersClient;
1919
import com.pipedream.api.resources.users.AsyncUsersClient;
20+
import com.pipedream.api.resources.workflows.AsyncWorkflowsClient;
2021
import java.util.function.Supplier;
2122

2223
public class AsyncBaseClient {
@@ -46,6 +47,8 @@ public class AsyncBaseClient {
4647

4748
protected final Supplier<AsyncOauthTokensClient> oauthTokensClient;
4849

50+
protected final Supplier<AsyncWorkflowsClient> workflowsClient;
51+
4952
public AsyncBaseClient(ClientOptions clientOptions) {
5053
this.clientOptions = clientOptions;
5154
this.appCategoriesClient = Suppliers.memoize(() -> new AsyncAppCategoriesClient(clientOptions));
@@ -60,6 +63,7 @@ public AsyncBaseClient(ClientOptions clientOptions) {
6063
this.proxyClient = Suppliers.memoize(() -> new AsyncProxyClient(clientOptions));
6164
this.tokensClient = Suppliers.memoize(() -> new AsyncTokensClient(clientOptions));
6265
this.oauthTokensClient = Suppliers.memoize(() -> new AsyncOauthTokensClient(clientOptions));
66+
this.workflowsClient = Suppliers.memoize(() -> new AsyncWorkflowsClient(clientOptions));
6367
}
6468

6569
public AsyncAppCategoriesClient appCategories() {
@@ -110,6 +114,10 @@ public AsyncOauthTokensClient oauthTokens() {
110114
return this.oauthTokensClient.get();
111115
}
112116

117+
public AsyncWorkflowsClient workflows() {
118+
return this.workflowsClient.get();
119+
}
120+
113121
public static AsyncBaseClientBuilder builder() {
114122
return new AsyncBaseClientBuilder();
115123
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import com.pipedream.api.core.ClientOptions;
44
import com.pipedream.api.core.Environment;
5-
import org.immutables.value.Value;
6-
75
import java.util.Optional;
6+
import org.immutables.value.Value;
87

98
@Value
109
public class AsyncPipedreamClient extends AsyncBaseClient {
@@ -19,7 +18,6 @@ public static AsyncPipedreamClientBuilder builder() {
1918
.environment(Environment.PROD)
2019
.projectEnvironment(System.getenv("PIPEDREAM_PROJECT_ENVIRONMENT"))
2120
.projectId(System.getenv("PIPEDREAM_PROJECT_ID"));
22-
2321
}
2422

2523
/**
@@ -28,15 +26,11 @@ public static AsyncPipedreamClientBuilder builder() {
2826
* @return the access token string (if available)
2927
*/
3028
public Optional<String> rawAccessToken() {
31-
final String authorizationHeader = this.clientOptions
32-
.headers(null)
33-
.get("Authorization");
29+
final String authorizationHeader = this.clientOptions.headers(null).get("Authorization");
3430

3531
// The header might not be defined, so we wrap it as an Optional to
3632
// further process it. The processing consists of removing the `Bearer`
3733
// or `Basic` prefix from the header value.
38-
return Optional
39-
.ofNullable(authorizationHeader)
40-
.map(h -> h.replaceFirst("^.*?\\s+", ""));
34+
return Optional.ofNullable(authorizationHeader).map(h -> h.replaceFirst("^.*?\\s+", ""));
4135
}
4236
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public void setVariables(ClientOptions.Builder builder) {
3333
}
3434

3535
private static String patchUrl(final String templateUrl) {
36-
StringSubstitutor sub = new StringSubstitutor(
37-
StringLookupFactory.INSTANCE.environmentVariableStringLookup()
38-
);
36+
StringSubstitutor sub = new StringSubstitutor(StringLookupFactory.INSTANCE.environmentVariableStringLookup());
3937

4038
return sub.replace(templateUrl);
4139
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.pipedream.api.resources.tokens.TokensClient;
1818
import com.pipedream.api.resources.triggers.TriggersClient;
1919
import com.pipedream.api.resources.users.UsersClient;
20+
import com.pipedream.api.resources.workflows.WorkflowsClient;
2021
import java.util.function.Supplier;
2122

2223
public class BaseClient {
@@ -46,6 +47,8 @@ public class BaseClient {
4647

4748
protected final Supplier<OauthTokensClient> oauthTokensClient;
4849

50+
protected final Supplier<WorkflowsClient> workflowsClient;
51+
4952
public BaseClient(ClientOptions clientOptions) {
5053
this.clientOptions = clientOptions;
5154
this.appCategoriesClient = Suppliers.memoize(() -> new AppCategoriesClient(clientOptions));
@@ -60,6 +63,7 @@ public BaseClient(ClientOptions clientOptions) {
6063
this.proxyClient = Suppliers.memoize(() -> new ProxyClient(clientOptions));
6164
this.tokensClient = Suppliers.memoize(() -> new TokensClient(clientOptions));
6265
this.oauthTokensClient = Suppliers.memoize(() -> new OauthTokensClient(clientOptions));
66+
this.workflowsClient = Suppliers.memoize(() -> new WorkflowsClient(clientOptions));
6367
}
6468

6569
public AppCategoriesClient appCategories() {
@@ -110,6 +114,10 @@ public OauthTokensClient oauthTokens() {
110114
return this.oauthTokensClient.get();
111115
}
112116

117+
public WorkflowsClient workflows() {
118+
return this.workflowsClient.get();
119+
}
120+
113121
public static BaseClientBuilder builder() {
114122
return new BaseClientBuilder();
115123
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import com.pipedream.api.core.ClientOptions;
44
import com.pipedream.api.core.Environment;
5-
import org.immutables.value.Value;
6-
75
import java.util.Optional;
6+
import org.immutables.value.Value;
87

98
@Value
109
public class PipedreamClient extends BaseClient {
@@ -19,7 +18,6 @@ public static PipedreamClientBuilder builder() {
1918
.environment(Environment.PROD)
2019
.projectEnvironment(System.getenv("PIPEDREAM_PROJECT_ENVIRONMENT"))
2120
.projectId(System.getenv("PIPEDREAM_PROJECT_ID"));
22-
2321
}
2422

2523
/**
@@ -28,15 +26,11 @@ public static PipedreamClientBuilder builder() {
2826
* @return the access token string (if available)
2927
*/
3028
public Optional<String> rawAccessToken() {
31-
final String authorizationHeader = this.clientOptions
32-
.headers(null)
33-
.get("Authorization");
29+
final String authorizationHeader = this.clientOptions.headers(null).get("Authorization");
3430

3531
// The header might not be defined, so we wrap it as an Optional to
3632
// further process it. The processing consists of removing the `Bearer`
3733
// or `Basic` prefix from the header value.
38-
return Optional
39-
.ofNullable(authorizationHeader)
40-
.map(h -> h.replaceFirst("^.*?\\s+", ""));
34+
return Optional.ofNullable(authorizationHeader).map(h -> h.replaceFirst("^.*?\\s+", ""));
4135
}
4236
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public void setVariables(ClientOptions.Builder builder) {
3333
}
3434

3535
private static String patchUrl(final String templateUrl) {
36-
StringSubstitutor sub = new StringSubstitutor(
37-
StringLookupFactory.INSTANCE.environmentVariableStringLookup()
38-
);
36+
StringSubstitutor sub = new StringSubstitutor(StringLookupFactory.INSTANCE.environmentVariableStringLookup());
3937

4038
return sub.replace(templateUrl);
4139
}

0 commit comments

Comments
 (0)