headers = new HashMap<>();
- if (request.getHeaders().isPresent()) {
- headers.putAll(request.getHeaders().get());
- }
- headers.put("X-PD-External-User-ID", request.getExternalUserId());
-
- // Create a new request with the authentication from the original request and the external user header
- InvokeWorkflowOpts invokeRequest = InvokeWorkflowOpts.builder()
- .urlOrEndpoint(request.getUrl())
- .body(request.getBody())
- .headers(headers)
- .method(request.getMethod())
- .authType(request.getAuthType().orElse(HTTPAuthType.OAUTH))
- .build();
-
- return invoke(invokeRequest, requestOptions);
- }
-
- /**
- * Builds a full workflow URL based on the input.
- *
- * @param input Either a full URL (with or without protocol) or just an endpoint ID.
- * @return The fully constructed URL.
- */
- private String buildWorkflowUrl(String input) {
- String sanitizedInput = input.trim().toLowerCase();
- if (sanitizedInput.isEmpty()) {
- throw new IllegalArgumentException("URL or endpoint ID is required");
- }
-
- // Check if it's already a full URL
- if (sanitizedInput.startsWith("http://") || sanitizedInput.startsWith("https://")) {
- try {
- URL url = new URL(input);
- // Validate the hostname
- String workflowDomain = this.workflowDomain;
- if (!url.getHost().endsWith(this.workflowDomain)) {
- throw new IllegalArgumentException(
- "Invalid workflow domain. URL must end with " + this.workflowDomain);
- }
- return input;
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException("The provided URL is malformed: " + input, e);
- }
- }
-
- // Check if it's a URL without protocol
- if (sanitizedInput.contains(".")) {
- return buildWorkflowUrl("https://" + input);
- }
-
- // It's an endpoint ID
- if (!sanitizedInput.matches("^e[no][a-z0-9-]+$")) {
- throw new IllegalArgumentException(
- "Invalid endpoint ID format. Must contain only letters, numbers, and hyphens, "
- + "and start with either 'en' or 'eo'.");
- }
-
- return urlProtocol + "://" + sanitizedInput + "." + workflowDomain;
- }
-
- private String getDefaultWorkflowDomain() {
- String envUrl = clientOptions.environment().getUrl();
- // For non-prod environments (dev, staging), use dev domain
- if (!envUrl.equals("https://api.pipedream.com") && !envUrl.equals("https://api2.pipedream.com")) {
- return "m.d.pipedream.net";
- }
- // For prod and canary, use standard domain
- return "m.pipedream.net";
- }
-
- private String getUrlProtocol() {
- String envUrl = clientOptions.environment().getUrl();
- // For non-prod environments (dev, staging), use http
- if (!envUrl.equals("https://api.pipedream.com") && !envUrl.equals("https://api2.pipedream.com")) {
- return "http";
- }
- // For prod and canary, use https
- return "https";
- }
-}
diff --git a/src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java
deleted file mode 100644
index 935ce7d..0000000
--- a/src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * This file was manually created to add workflow invocation support.
- */
-package com.pipedream.api.resources.workflows;
-
-import com.pipedream.api.core.ClientOptions;
-import com.pipedream.api.core.RequestOptions;
-import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts;
-import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts;
-
-public class WorkflowsClient {
- protected final ClientOptions clientOptions;
-
- private final RawWorkflowsClient rawClient;
-
- public WorkflowsClient(ClientOptions clientOptions) {
- this.clientOptions = clientOptions;
- this.rawClient = new RawWorkflowsClient(clientOptions);
- }
-
- /**
- * Get responses with HTTP metadata like headers
- */
- public RawWorkflowsClient withRawResponse() {
- return this.rawClient;
- }
-
- /**
- * Invokes a workflow using the URL of its HTTP interface(s).
- *
- * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint
- * @return The response from the workflow
- */
- public Object invoke(String urlOrEndpoint) {
- InvokeWorkflowOpts request =
- InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build();
- return this.rawClient.invoke(request).body();
- }
-
- /**
- * Invokes a workflow using the URL of its HTTP interface(s).
- *
- * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint
- * @param requestOptions Additional request options
- * @return The response from the workflow
- */
- public Object invoke(String urlOrEndpoint, RequestOptions requestOptions) {
- InvokeWorkflowOpts request =
- InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build();
- return this.rawClient.invoke(request, requestOptions).body();
- }
-
- /**
- * Invokes a workflow using the InvokeWorkflowOpts request object.
- *
- * @param request The request containing workflow invocation parameters
- * @return The response from the workflow
- */
- public Object invoke(InvokeWorkflowOpts request) {
- return this.rawClient.invoke(request).body();
- }
-
- /**
- * Invokes a workflow using the InvokeWorkflowOpts request object.
- *
- * @param request The request containing workflow invocation parameters
- * @param requestOptions Additional request options
- * @return The response from the workflow
- */
- public Object invoke(InvokeWorkflowOpts request, RequestOptions requestOptions) {
- return this.rawClient.invoke(request, requestOptions).body();
- }
-
- /**
- * Invokes a workflow for a Pipedream Connect user in a project.
- *
- * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint
- * @param externalUserId Your end user ID, for whom you're invoking the workflow
- * @return The response from the workflow
- */
- public Object invokeForExternalUser(String urlOrEndpoint, String externalUserId) {
- InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder()
- .url(urlOrEndpoint)
- .externalUserId(externalUserId)
- .build();
- return this.rawClient.invokeForExternalUser(request).body();
- }
-
- /**
- * Invokes a workflow for a Pipedream Connect user in a project.
- *
- * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint
- * @param externalUserId Your end user ID, for whom you're invoking the workflow
- * @param requestOptions Additional request options
- * @return The response from the workflow
- */
- public Object invokeForExternalUser(String urlOrEndpoint, String externalUserId, RequestOptions requestOptions) {
- InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder()
- .url(urlOrEndpoint)
- .externalUserId(externalUserId)
- .build();
- return this.rawClient.invokeForExternalUser(request, requestOptions).body();
- }
-
- /**
- * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object.
- *
- * @param request The request containing workflow invocation parameters
- * @return The response from the workflow
- */
- public Object invokeForExternalUser(InvokeWorkflowForExternalUserOpts request) {
- return this.rawClient.invokeForExternalUser(request).body();
- }
-
- /**
- * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object.
- *
- * @param request The request containing workflow invocation parameters
- * @param requestOptions Additional request options
- * @return The response from the workflow
- */
- public Object invokeForExternalUser(InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) {
- return this.rawClient.invokeForExternalUser(request, requestOptions).body();
- }
-}
diff --git a/src/main/java/com/pipedream/api/resources/workflows/package-info.java b/src/main/java/com/pipedream/api/resources/workflows/package-info.java
deleted file mode 100644
index cbd2a49..0000000
--- a/src/main/java/com/pipedream/api/resources/workflows/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * This package contains client classes for invoking Pipedream workflows.
- *
- * The workflows package provides functionality to:
- *
- * - Invoke workflows using their HTTP interface URLs or endpoint IDs
- * - Invoke workflows on behalf of external users (Pipedream Connect)
- * - Support both synchronous and asynchronous invocation patterns
- *
- *
- * Example usage:
- *
- * // Invoke a workflow
- * Object response = client.workflows().invoke("https://your-workflow.m.pipedream.net",
- * "POST", Map.of("key", "value"), null, HTTPAuthType.OAUTH);
- *
- * // Invoke a workflow for an external user
- * Object response = client.workflows().invokeForExternalUser(
- * "https://your-workflow.m.pipedream.net",
- * "external-user-123",
- * "POST",
- * Map.of("data", "payload"),
- * null
- * );
- *
- */
-package com.pipedream.api.resources.workflows;
diff --git a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java b/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java
deleted file mode 100644
index 296fb55..0000000
--- a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * This file was manually created to add workflow invocation support.
- */
-package com.pipedream.api.resources.workflows.requests;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonSetter;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.pipedream.api.types.HTTPAuthType;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-@JsonInclude(JsonInclude.Include.NON_ABSENT)
-@JsonDeserialize(builder = InvokeWorkflowForExternalUserOpts.Builder.class)
-public final class InvokeWorkflowForExternalUserOpts {
- private final String url;
-
- private final String externalUserId;
-
- private final Optional