diff --git a/README.md b/README.md index 9d4aea9..39cf3a8 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Add the dependency in your `pom.xml` file: com.pipedream pipedream - 0.0.256 + 0.0.262 ``` diff --git a/build.gradle b/build.gradle index def2d8c..4396096 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,7 @@ java { group = 'com.pipedream' -version = '0.0.256' +version = '0.0.262' jar { dependsOn(":generatePomFileForMavenPublication") @@ -79,7 +79,7 @@ publishing { maven(MavenPublication) { groupId = 'com.pipedream' artifactId = 'pipedream' - version = '0.0.256' + version = '0.0.262' from components.java pom { name = 'pipedream' diff --git a/reference.md b/reference.md index 42da24f..65ccf59 100644 --- a/reference.md +++ b/reference.md @@ -2289,7 +2289,7 @@ client.projects().retrieveInfo("project_id"); ## Proxy -
client.proxy.get(url, request) -> Object +
client.proxy.get(projectId, url64) -> Object
@@ -2303,7 +2303,8 @@ client.projects().retrieveInfo("project_id"); ```java client.proxy().get( - "https://api.example.com/endpoint", + "project_id", + "url_64", ProxyGetRequest .builder() .externalUserId("external_user_id") @@ -2324,7 +2325,15 @@ client.proxy().get(
-**url:** `String` — The target URL to proxy the request to +**projectId:** `String` — The project ID, which starts with 'proj_'. + +
+
+ +
+
+ +**url64:** `String` — Base64-encoded target URL
@@ -2347,19 +2356,12 @@ client.proxy().get(
-#### 📄 Response - -The proxy methods intelligently handle responses: -- **JSON responses**: Automatically parsed and returned as structured objects -- **Non-JSON responses**: Returned as raw strings (HTML, XML, plain text, etc.) -- **Empty responses**: Return `null` -
-
client.proxy.post(url, request) -> Object +
client.proxy.post(projectId, url64, request) -> Object
@@ -2373,7 +2375,8 @@ The proxy methods intelligently handle responses: ```java client.proxy().post( - "https://api.example.com/endpoint", + "project_id", + "url_64", ProxyPostRequest .builder() .externalUserId("external_user_id") @@ -2399,7 +2402,15 @@ client.proxy().post(
-**url:** `String` — The target URL to proxy the request to +**projectId:** `String` — The project ID, which starts with 'proj_'. + +
+
+ +
+
+ +**url64:** `String` — Base64-encoded target URL
@@ -2435,7 +2446,7 @@ client.proxy().post(
-
client.proxy.put(url, request) -> Object +
client.proxy.put(projectId, url64, request) -> Object
@@ -2449,7 +2460,8 @@ client.proxy().post( ```java client.proxy().put( - "https://api.example.com/endpoint", + "project_id", + "url_64", ProxyPutRequest .builder() .externalUserId("external_user_id") @@ -2475,7 +2487,15 @@ client.proxy().put(
-**url:** `String` — The target URL to proxy the request to +**projectId:** `String` — The project ID, which starts with 'proj_'. + +
+
+ +
+
+ +**url64:** `String` — Base64-encoded target URL
@@ -2511,7 +2531,7 @@ client.proxy().put(
-
client.proxy.delete(url, request) -> Object +
client.proxy.delete(projectId, url64) -> Object
@@ -2525,7 +2545,8 @@ client.proxy().put( ```java client.proxy().delete( - "https://api.example.com/endpoint", + "project_id", + "url_64", ProxyDeleteRequest .builder() .externalUserId("external_user_id") @@ -2546,7 +2567,15 @@ client.proxy().delete(
-**url:** `String` — The target URL to proxy the request to +**projectId:** `String` — The project ID, which starts with 'proj_'. + +
+
+ +
+
+ +**url64:** `String` — Base64-encoded target URL
@@ -2574,7 +2603,7 @@ client.proxy().delete(
-
client.proxy.patch(url, request) -> Object +
client.proxy.patch(projectId, url64, request) -> Object
@@ -2588,7 +2617,8 @@ client.proxy().delete( ```java client.proxy().patch( - "https://api.example.com/endpoint", + "project_id", + "url_64", ProxyPatchRequest .builder() .externalUserId("external_user_id") @@ -2614,7 +2644,15 @@ client.proxy().patch(
-**url:** `String` — The target URL to proxy the request to +**projectId:** `String` — The project ID, which starts with 'proj_'. + +
+
+ +
+
+ +**url64:** `String` — Base64-encoded target URL
@@ -2795,205 +2833,6 @@ client.tokens().validate(
- - -
- -## Workflows -
client.workflows.invoke(urlOrEndpoint) -> Object -
-
- -#### 🔌 Usage - -
-
- -
-
- -```java -// Simple workflow invocation (uses OAuth authentication by default) -client.workflows().invoke("eo3xxxx"); - -// Advanced workflow invocation with all options -client.workflows().invoke( - InvokeWorkflowOpts - .builder() - .urlOrEndpoint("https://eo3xxxx.m.pipedream.net") - .body( - new HashMap() {{ - put("name", "John Doe"); - put("email", "john@example.com"); - }} - ) - .headers( - new HashMap() {{ - put("Content-Type", "application/json"); - put("Authorization", "Bearer your-token"); // For STATIC_BEARER auth - }} - ) - .method("POST") - .authType(HTTPAuthType.STATIC_BEARER) - .build() -); -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**urlOrEndpoint:** `String` — Either a workflow endpoint ID (e.g., 'eo3xxxx') or a full workflow URL - -
-
- -
-
- -**body:** `Optional` — Request body to send to the workflow (will be JSON serialized) - - - - -
-
- -**headers:** `Optional>` — Additional headers to include in the request - -
-
- -
-
- -**method:** `Optional` — HTTP method to use (defaults to 'POST') - -
-
- -
-
- -**authType:** `Optional` — Authentication type: OAUTH (default), STATIC_BEARER, or NONE - -
-
- - - - - - - - -
client.workflows.invokeForExternalUser(urlOrEndpoint, externalUserId) -> Object -
-
- -#### 🔌 Usage - -
-
- -
-
- -```java -// Simple external user invocation (uses OAuth authentication by default) -client.workflows().invokeForExternalUser("eo3xxxx", "user123"); - -// Advanced external user invocation with all options -client.workflows().invokeForExternalUser( - InvokeWorkflowForExternalUserOpts - .builder() - .url("https://eo3xxxx.m.pipedream.net") - .externalUserId("user123") - .body( - new HashMap() {{ - put("action", "process_data"); - put("data", Arrays.asList("item1", "item2")); - }} - ) - .headers( - new HashMap() {{ - put("X-Custom-Header", "value"); - }} - ) - .method("POST") - .authType(HTTPAuthType.OAUTH) - .build() -); -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**url:** `String` — The full workflow URL to invoke - -
-
- -
-
- -**externalUserId:** `String` — The external user ID for Pipedream Connect authentication - -
-
- -
-
- -**body:** `Optional` — Request body to send to the workflow (will be JSON serialized) - - - - -
-
- -**headers:** `Optional>` — Additional headers to include in the request - -
-
- -
-
- -**method:** `Optional` — HTTP method to use (defaults to 'POST') - -
-
- -
-
- -**authType:** `Optional` — Authentication type: OAUTH (default), STATIC_BEARER, or NONE - -
-
- - - - diff --git a/src/main/java/com/pipedream/api/core/ClientOptions.java b/src/main/java/com/pipedream/api/core/ClientOptions.java index 2e7459a..d23e57b 100644 --- a/src/main/java/com/pipedream/api/core/ClientOptions.java +++ b/src/main/java/com/pipedream/api/core/ClientOptions.java @@ -37,7 +37,7 @@ private ClientOptions( { put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.pipedream.fern:api-sdk"); - put("X-Fern-SDK-Version", "0.0.256"); + put("X-Fern-SDK-Version", "0.0.262"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java index bb0aa7f..fd06a93 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java @@ -10,7 +10,6 @@ import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest; import com.pipedream.api.resources.proxy.requests.ProxyPostRequest; import com.pipedream.api.resources.proxy.requests.ProxyPutRequest; -import java.util.Base64; import java.util.concurrent.CompletableFuture; public class AsyncProxyClient { @@ -30,57 +29,43 @@ public AsyncRawProxyClient withRawResponse() { return this.rawClient; } - private String encodeUrl(String url) { - return Base64.getUrlEncoder().encodeToString(url.getBytes()); - } - - public CompletableFuture get(String url, ProxyGetRequest request) { - final String url64 = encodeUrl(url); + public CompletableFuture get(String url64, ProxyGetRequest request) { return this.rawClient.get(url64, request).thenApply(response -> response.body()); } - public CompletableFuture get(String url, ProxyGetRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public CompletableFuture get(String url64, ProxyGetRequest request, RequestOptions requestOptions) { return this.rawClient.get(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture post(String url, ProxyPostRequest request) { - final String url64 = encodeUrl(url); + public CompletableFuture post(String url64, ProxyPostRequest request) { return this.rawClient.post(url64, request).thenApply(response -> response.body()); } - public CompletableFuture post(String url, ProxyPostRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public CompletableFuture post(String url64, ProxyPostRequest request, RequestOptions requestOptions) { return this.rawClient.post(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture put(String url, ProxyPutRequest request) { - final String url64 = encodeUrl(url); + public CompletableFuture put(String url64, ProxyPutRequest request) { return this.rawClient.put(url64, request).thenApply(response -> response.body()); } - public CompletableFuture put(String url, ProxyPutRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public CompletableFuture put(String url64, ProxyPutRequest request, RequestOptions requestOptions) { return this.rawClient.put(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture delete(String url, ProxyDeleteRequest request) { - final String url64 = encodeUrl(url); + public CompletableFuture delete(String url64, ProxyDeleteRequest request) { return this.rawClient.delete(url64, request).thenApply(response -> response.body()); } - public CompletableFuture delete(String url, ProxyDeleteRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public CompletableFuture delete(String url64, ProxyDeleteRequest request, RequestOptions requestOptions) { return this.rawClient.delete(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture patch(String url, ProxyPatchRequest request) { - final String url64 = encodeUrl(url); + public CompletableFuture patch(String url64, ProxyPatchRequest request) { return this.rawClient.patch(url64, request).thenApply(response -> response.body()); } - public CompletableFuture patch(String url, ProxyPatchRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public CompletableFuture patch(String url64, ProxyPatchRequest request, RequestOptions requestOptions) { return this.rawClient.patch(url64, request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java index 7d4f634..24f27f3 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java @@ -36,17 +36,6 @@ public AsyncRawProxyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - private Object parseResponse(String responseBodyString) { - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - return null; - } - try { - return ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception jsonException) { - return responseBodyString; - } - } - public CompletableFuture> get(String url64, ProxyGetRequest request) { return get(url64, request, null); } @@ -77,20 +66,15 @@ public CompletableFuture> get( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -144,20 +128,15 @@ public CompletableFuture> post( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -211,20 +190,15 @@ public CompletableFuture> put( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -270,20 +244,15 @@ public CompletableFuture> delete( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -337,20 +306,15 @@ public CompletableFuture> patch( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { diff --git a/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java index 0e4781b..a7e22d7 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java @@ -10,7 +10,6 @@ import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest; import com.pipedream.api.resources.proxy.requests.ProxyPostRequest; import com.pipedream.api.resources.proxy.requests.ProxyPutRequest; -import java.util.Base64; public class ProxyClient { protected final ClientOptions clientOptions; @@ -29,57 +28,43 @@ public RawProxyClient withRawResponse() { return this.rawClient; } - private String encodeUrl(String url) { - return Base64.getUrlEncoder().encodeToString(url.getBytes()); - } - - public Object get(String url, ProxyGetRequest request) { - final String url64 = encodeUrl(url); + public Object get(String url64, ProxyGetRequest request) { return this.rawClient.get(url64, request).body(); } - public Object get(String url, ProxyGetRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public Object get(String url64, ProxyGetRequest request, RequestOptions requestOptions) { return this.rawClient.get(url64, request, requestOptions).body(); } - public Object post(String url, ProxyPostRequest request) { - final String url64 = encodeUrl(url); + public Object post(String url64, ProxyPostRequest request) { return this.rawClient.post(url64, request).body(); } - public Object post(String url, ProxyPostRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public Object post(String url64, ProxyPostRequest request, RequestOptions requestOptions) { return this.rawClient.post(url64, request, requestOptions).body(); } - public Object put(String url, ProxyPutRequest request) { - final String url64 = encodeUrl(url); + public Object put(String url64, ProxyPutRequest request) { return this.rawClient.put(url64, request).body(); } - public Object put(String url, ProxyPutRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public Object put(String url64, ProxyPutRequest request, RequestOptions requestOptions) { return this.rawClient.put(url64, request, requestOptions).body(); } - public Object delete(String url, ProxyDeleteRequest request) { - final String url64 = encodeUrl(url); + public Object delete(String url64, ProxyDeleteRequest request) { return this.rawClient.delete(url64, request).body(); } - public Object delete(String url, ProxyDeleteRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public Object delete(String url64, ProxyDeleteRequest request, RequestOptions requestOptions) { return this.rawClient.delete(url64, request, requestOptions).body(); } - public Object patch(String url, ProxyPatchRequest request) { - final String url64 = encodeUrl(url); + public Object patch(String url64, ProxyPatchRequest request) { return this.rawClient.patch(url64, request).body(); } - public Object patch(String url, ProxyPatchRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + public Object patch(String url64, ProxyPatchRequest request, RequestOptions requestOptions) { return this.rawClient.patch(url64, request, requestOptions).body(); } } diff --git a/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java index 7e75266..8bfb9ec 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java @@ -32,17 +32,6 @@ public RawProxyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - private Object parseResponse(String responseBodyString) { - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - return null; - } - try { - return ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception jsonException) { - return responseBodyString; - } - } - public BaseClientHttpResponse get(String url64, ProxyGetRequest request) { return get(url64, request, null); } @@ -69,15 +58,14 @@ public BaseClientHttpResponse get(String url64, ProxyGetRequest request, try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); @@ -118,15 +106,14 @@ public BaseClientHttpResponse post(String url64, ProxyPostRequest reques try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); @@ -167,15 +154,14 @@ public BaseClientHttpResponse put(String url64, ProxyPutRequest request, try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); @@ -209,15 +195,14 @@ public BaseClientHttpResponse delete( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); @@ -259,15 +244,14 @@ public BaseClientHttpResponse patch( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyDeleteRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyDeleteRequest.java deleted file mode 100644 index f956f17..0000000 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyDeleteRequest.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.pipedream.api.resources.proxy.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -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.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ProxyDeleteRequest.Builder.class) -public final class ProxyDeleteRequest { - private final String externalUserId; - - private final String accountId; - - private final Map additionalProperties; - - private ProxyDeleteRequest(String externalUserId, String accountId, Map additionalProperties) { - this.externalUserId = externalUserId; - this.accountId = accountId; - this.additionalProperties = additionalProperties; - } - - /** - * @return The external user ID for the proxy request - */ - @JsonProperty("external_user_id") - public String getExternalUserId() { - return externalUserId; - } - - /** - * @return The account ID to use for authentication - */ - @JsonProperty("account_id") - public String getAccountId() { - return accountId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProxyDeleteRequest && equalTo((ProxyDeleteRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProxyDeleteRequest other) { - return externalUserId.equals(other.externalUserId) && accountId.equals(other.accountId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.externalUserId, this.accountId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ExternalUserIdStage builder() { - return new Builder(); - } - - public interface ExternalUserIdStage { - /** - *

The external user ID for the proxy request

- */ - AccountIdStage externalUserId(@NotNull String externalUserId); - - Builder from(ProxyDeleteRequest other); - } - - public interface AccountIdStage { - /** - *

The account ID to use for authentication

- */ - _FinalStage accountId(@NotNull String accountId); - } - - public interface _FinalStage { - ProxyDeleteRequest build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ExternalUserIdStage, AccountIdStage, _FinalStage { - private String externalUserId; - - private String accountId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ProxyDeleteRequest other) { - externalUserId(other.getExternalUserId()); - accountId(other.getAccountId()); - return this; - } - - /** - *

The external user ID for the proxy request

- *

The external user ID for the proxy request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("external_user_id") - public AccountIdStage externalUserId(@NotNull String externalUserId) { - this.externalUserId = Objects.requireNonNull(externalUserId, "externalUserId must not be null"); - return this; - } - - /** - *

The account ID to use for authentication

- *

The account ID to use for authentication

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("account_id") - public _FinalStage accountId(@NotNull String accountId) { - this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); - return this; - } - - @java.lang.Override - public ProxyDeleteRequest build() { - return new ProxyDeleteRequest(externalUserId, accountId, additionalProperties); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyGetRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyGetRequest.java deleted file mode 100644 index bf09229..0000000 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyGetRequest.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.pipedream.api.resources.proxy.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -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.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ProxyGetRequest.Builder.class) -public final class ProxyGetRequest { - private final String externalUserId; - - private final String accountId; - - private final Map additionalProperties; - - private ProxyGetRequest(String externalUserId, String accountId, Map additionalProperties) { - this.externalUserId = externalUserId; - this.accountId = accountId; - this.additionalProperties = additionalProperties; - } - - /** - * @return The external user ID for the proxy request - */ - @JsonProperty("external_user_id") - public String getExternalUserId() { - return externalUserId; - } - - /** - * @return The account ID to use for authentication - */ - @JsonProperty("account_id") - public String getAccountId() { - return accountId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProxyGetRequest && equalTo((ProxyGetRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProxyGetRequest other) { - return externalUserId.equals(other.externalUserId) && accountId.equals(other.accountId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.externalUserId, this.accountId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ExternalUserIdStage builder() { - return new Builder(); - } - - public interface ExternalUserIdStage { - /** - *

The external user ID for the proxy request

- */ - AccountIdStage externalUserId(@NotNull String externalUserId); - - Builder from(ProxyGetRequest other); - } - - public interface AccountIdStage { - /** - *

The account ID to use for authentication

- */ - _FinalStage accountId(@NotNull String accountId); - } - - public interface _FinalStage { - ProxyGetRequest build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ExternalUserIdStage, AccountIdStage, _FinalStage { - private String externalUserId; - - private String accountId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ProxyGetRequest other) { - externalUserId(other.getExternalUserId()); - accountId(other.getAccountId()); - return this; - } - - /** - *

The external user ID for the proxy request

- *

The external user ID for the proxy request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("external_user_id") - public AccountIdStage externalUserId(@NotNull String externalUserId) { - this.externalUserId = Objects.requireNonNull(externalUserId, "externalUserId must not be null"); - return this; - } - - /** - *

The account ID to use for authentication

- *

The account ID to use for authentication

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("account_id") - public _FinalStage accountId(@NotNull String accountId) { - this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); - return this; - } - - @java.lang.Override - public ProxyGetRequest build() { - return new ProxyGetRequest(externalUserId, accountId, additionalProperties); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java deleted file mode 100644 index fe68355..0000000 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.pipedream.api.resources.proxy.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -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.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.pipedream.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ProxyPatchRequest.Builder.class) -public final class ProxyPatchRequest { - private final String externalUserId; - - private final String accountId; - - private final Map body; - - private final Map additionalProperties; - - private ProxyPatchRequest( - String externalUserId, - String accountId, - Map body, - Map additionalProperties) { - this.externalUserId = externalUserId; - this.accountId = accountId; - this.body = body; - this.additionalProperties = additionalProperties; - } - - /** - * @return The external user ID for the proxy request - */ - @JsonProperty("external_user_id") - public String getExternalUserId() { - return externalUserId; - } - - /** - * @return The account ID to use for authentication - */ - @JsonProperty("account_id") - public String getAccountId() { - return accountId; - } - - /** - * @return Request body to forward to the target API - */ - @JsonProperty("body") - public Map getBody() { - return body; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProxyPatchRequest && equalTo((ProxyPatchRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProxyPatchRequest other) { - return externalUserId.equals(other.externalUserId) - && accountId.equals(other.accountId) - && body.equals(other.body); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.externalUserId, this.accountId, this.body); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ExternalUserIdStage builder() { - return new Builder(); - } - - public interface ExternalUserIdStage { - /** - *

The external user ID for the proxy request

- */ - AccountIdStage externalUserId(@NotNull String externalUserId); - - Builder from(ProxyPatchRequest other); - } - - public interface AccountIdStage { - /** - *

The account ID to use for authentication

- */ - _FinalStage accountId(@NotNull String accountId); - } - - public interface _FinalStage { - ProxyPatchRequest build(); - - /** - *

Request body to forward to the target API

- */ - _FinalStage body(Map body); - - _FinalStage putAllBody(Map body); - - _FinalStage body(String key, Object value); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ExternalUserIdStage, AccountIdStage, _FinalStage { - private String externalUserId; - - private String accountId; - - private Map body = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ProxyPatchRequest other) { - externalUserId(other.getExternalUserId()); - accountId(other.getAccountId()); - body(other.getBody()); - return this; - } - - /** - *

The external user ID for the proxy request

- *

The external user ID for the proxy request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("external_user_id") - public AccountIdStage externalUserId(@NotNull String externalUserId) { - this.externalUserId = Objects.requireNonNull(externalUserId, "externalUserId must not be null"); - return this; - } - - /** - *

The account ID to use for authentication

- *

The account ID to use for authentication

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("account_id") - public _FinalStage accountId(@NotNull String accountId) { - this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); - return this; - } - - /** - *

Request body to forward to the target API

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage body(String key, Object value) { - this.body.put(key, value); - return this; - } - - /** - *

Request body to forward to the target API

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage putAllBody(Map body) { - this.body.putAll(body); - return this; - } - - /** - *

Request body to forward to the target API

- */ - @java.lang.Override - @JsonSetter(value = "body", nulls = Nulls.SKIP) - public _FinalStage body(Map body) { - this.body.clear(); - this.body.putAll(body); - return this; - } - - @java.lang.Override - public ProxyPatchRequest build() { - return new ProxyPatchRequest(externalUserId, accountId, body, additionalProperties); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java deleted file mode 100644 index d648ab4..0000000 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.pipedream.api.resources.proxy.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -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.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.pipedream.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ProxyPostRequest.Builder.class) -public final class ProxyPostRequest { - private final String externalUserId; - - private final String accountId; - - private final Map body; - - private final Map additionalProperties; - - private ProxyPostRequest( - String externalUserId, - String accountId, - Map body, - Map additionalProperties) { - this.externalUserId = externalUserId; - this.accountId = accountId; - this.body = body; - this.additionalProperties = additionalProperties; - } - - /** - * @return The external user ID for the proxy request - */ - @JsonProperty("external_user_id") - public String getExternalUserId() { - return externalUserId; - } - - /** - * @return The account ID to use for authentication - */ - @JsonProperty("account_id") - public String getAccountId() { - return accountId; - } - - /** - * @return Request body to forward to the target API - */ - @JsonProperty("body") - public Map getBody() { - return body; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProxyPostRequest && equalTo((ProxyPostRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProxyPostRequest other) { - return externalUserId.equals(other.externalUserId) - && accountId.equals(other.accountId) - && body.equals(other.body); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.externalUserId, this.accountId, this.body); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ExternalUserIdStage builder() { - return new Builder(); - } - - public interface ExternalUserIdStage { - /** - *

The external user ID for the proxy request

- */ - AccountIdStage externalUserId(@NotNull String externalUserId); - - Builder from(ProxyPostRequest other); - } - - public interface AccountIdStage { - /** - *

The account ID to use for authentication

- */ - _FinalStage accountId(@NotNull String accountId); - } - - public interface _FinalStage { - ProxyPostRequest build(); - - /** - *

Request body to forward to the target API

- */ - _FinalStage body(Map body); - - _FinalStage putAllBody(Map body); - - _FinalStage body(String key, Object value); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ExternalUserIdStage, AccountIdStage, _FinalStage { - private String externalUserId; - - private String accountId; - - private Map body = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ProxyPostRequest other) { - externalUserId(other.getExternalUserId()); - accountId(other.getAccountId()); - body(other.getBody()); - return this; - } - - /** - *

The external user ID for the proxy request

- *

The external user ID for the proxy request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("external_user_id") - public AccountIdStage externalUserId(@NotNull String externalUserId) { - this.externalUserId = Objects.requireNonNull(externalUserId, "externalUserId must not be null"); - return this; - } - - /** - *

The account ID to use for authentication

- *

The account ID to use for authentication

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("account_id") - public _FinalStage accountId(@NotNull String accountId) { - this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); - return this; - } - - /** - *

Request body to forward to the target API

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage body(String key, Object value) { - this.body.put(key, value); - return this; - } - - /** - *

Request body to forward to the target API

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage putAllBody(Map body) { - this.body.putAll(body); - return this; - } - - /** - *

Request body to forward to the target API

- */ - @java.lang.Override - @JsonSetter(value = "body", nulls = Nulls.SKIP) - public _FinalStage body(Map body) { - this.body.clear(); - this.body.putAll(body); - return this; - } - - @java.lang.Override - public ProxyPostRequest build() { - return new ProxyPostRequest(externalUserId, accountId, body, additionalProperties); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java deleted file mode 100644 index d4aaeba..0000000 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.pipedream.api.resources.proxy.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -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.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.pipedream.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ProxyPutRequest.Builder.class) -public final class ProxyPutRequest { - private final String externalUserId; - - private final String accountId; - - private final Map body; - - private final Map additionalProperties; - - private ProxyPutRequest( - String externalUserId, - String accountId, - Map body, - Map additionalProperties) { - this.externalUserId = externalUserId; - this.accountId = accountId; - this.body = body; - this.additionalProperties = additionalProperties; - } - - /** - * @return The external user ID for the proxy request - */ - @JsonProperty("external_user_id") - public String getExternalUserId() { - return externalUserId; - } - - /** - * @return The account ID to use for authentication - */ - @JsonProperty("account_id") - public String getAccountId() { - return accountId; - } - - /** - * @return Request body to forward to the target API - */ - @JsonProperty("body") - public Map getBody() { - return body; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProxyPutRequest && equalTo((ProxyPutRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProxyPutRequest other) { - return externalUserId.equals(other.externalUserId) - && accountId.equals(other.accountId) - && body.equals(other.body); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.externalUserId, this.accountId, this.body); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ExternalUserIdStage builder() { - return new Builder(); - } - - public interface ExternalUserIdStage { - /** - *

The external user ID for the proxy request

- */ - AccountIdStage externalUserId(@NotNull String externalUserId); - - Builder from(ProxyPutRequest other); - } - - public interface AccountIdStage { - /** - *

The account ID to use for authentication

- */ - _FinalStage accountId(@NotNull String accountId); - } - - public interface _FinalStage { - ProxyPutRequest build(); - - /** - *

Request body to forward to the target API

- */ - _FinalStage body(Map body); - - _FinalStage putAllBody(Map body); - - _FinalStage body(String key, Object value); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ExternalUserIdStage, AccountIdStage, _FinalStage { - private String externalUserId; - - private String accountId; - - private Map body = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ProxyPutRequest other) { - externalUserId(other.getExternalUserId()); - accountId(other.getAccountId()); - body(other.getBody()); - return this; - } - - /** - *

The external user ID for the proxy request

- *

The external user ID for the proxy request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("external_user_id") - public AccountIdStage externalUserId(@NotNull String externalUserId) { - this.externalUserId = Objects.requireNonNull(externalUserId, "externalUserId must not be null"); - return this; - } - - /** - *

The account ID to use for authentication

- *

The account ID to use for authentication

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("account_id") - public _FinalStage accountId(@NotNull String accountId) { - this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); - return this; - } - - /** - *

Request body to forward to the target API

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage body(String key, Object value) { - this.body.put(key, value); - return this; - } - - /** - *

Request body to forward to the target API

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage putAllBody(Map body) { - this.body.putAll(body); - return this; - } - - /** - *

Request body to forward to the target API

- */ - @java.lang.Override - @JsonSetter(value = "body", nulls = Nulls.SKIP) - public _FinalStage body(Map body) { - this.body.clear(); - this.body.putAll(body); - return this; - } - - @java.lang.Override - public ProxyPutRequest build() { - return new ProxyPutRequest(externalUserId, accountId, body, additionalProperties); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java deleted file mode 100644 index d523b9d..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java +++ /dev/null @@ -1,268 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows; - -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.MediaTypes; -import com.pipedream.api.core.ObjectMappers; -import com.pipedream.api.core.RequestOptions; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts; -import com.pipedream.api.types.HTTPAuthType; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -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.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class AsyncRawWorkflowsClient { - protected final ClientOptions clientOptions; - private final String workflowDomain; - private final String urlProtocol; - - public AsyncRawWorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.workflowDomain = getDefaultWorkflowDomain(); - this.urlProtocol = getUrlProtocol(); - } - - public CompletableFuture> invoke(InvokeWorkflowOpts request) { - return invoke(request, null); - } - - public CompletableFuture> invoke( - InvokeWorkflowOpts request, RequestOptions requestOptions) { - - // Build the workflow URL - String urlString = buildWorkflowUrl(request.getUrlOrEndpoint()); - - HttpUrl httpUrl; - try { - httpUrl = HttpUrl.parse(urlString); - if (httpUrl == null) { - throw new IllegalArgumentException("Invalid URL: " + urlString); - } - } catch (Exception e) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new IllegalArgumentException("Invalid URL: " + urlString, e)); - return future; - } - - // Determine auth type - default to OAuth if not specified - HTTPAuthType authType = request.getAuthType().orElse(HTTPAuthType.OAUTH); - - // Prepare headers - start with client options headers (includes OAuth auth if configured) - Map allHeaders = new HashMap<>(clientOptions.headers(requestOptions)); - - // Handle authentication based on type - if (authType == HTTPAuthType.OAUTH) { - // For OAuth, the Authorization header should already be in clientOptions.headers() - // No additional action needed - } else if (authType == HTTPAuthType.STATIC_BEARER) { - // For static_bearer, users must provide the Authorization header in request.getHeaders() - // Their header will override any existing OAuth header when we merge request headers - } else if (authType == HTTPAuthType.NONE) { - // For NONE auth type, set Authorization header to empty string (matches Python SDK) - allHeaders.put("Authorization", ""); - } - - // Add request-specific headers (can override auth headers for STATIC_BEARER) - if (request.getHeaders().isPresent()) { - allHeaders.putAll(request.getHeaders().get()); - } - - // Determine HTTP method - String method = request.getMethod().orElse("POST").toUpperCase(); - - // Prepare request body if needed - RequestBody body = null; - if (request.getBody().isPresent()) { - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes( - request.getBody().get()), - MediaTypes.APPLICATION_JSON); - allHeaders.put("Content-Type", "application/json"); - } catch (Exception e) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new RuntimeException("Failed to serialize request body", e)); - return future; - } - } else if (("POST".equals(method) || "PUT".equals(method) || "PATCH".equals(method))) { - // For methods that typically require a body, send an empty body - // to avoid OkHttp's "method POST must have a request body" error - body = RequestBody.create(new byte[0], null); - } - - // Build the request - Request.Builder requestBuilder = - new Request.Builder().url(httpUrl).method(method, body).headers(Headers.of(allHeaders)); - - if (!allHeaders.containsKey("Accept")) { - requestBuilder.addHeader("Accept", "application/json"); - } - - Request okhttpRequest = requestBuilder.build(); - - // Execute the request asynchronously - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - - CompletableFuture> future = new CompletableFuture<>(); - - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); - } - - @Override - public void onResponse(Call call, Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - Object parsedResponse; - try { - parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception e) { - // If JSON parsing fails, return the raw string - parsedResponse = responseBodyString; - } - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); - } else { - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - } - } catch (Exception e) { - future.completeExceptionally(e); - } - } - }); - - return future; - } - - public CompletableFuture> invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request) { - return invokeForExternalUser(request, null); - } - - public CompletableFuture> invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - - // Validate inputs - if (request.getExternalUserId() == null - || request.getExternalUserId().trim().isEmpty()) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new IllegalArgumentException("External user ID is required")); - return future; - } - - if (request.getUrl() == null || request.getUrl().trim().isEmpty()) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new IllegalArgumentException("Workflow URL is required")); - return future; - } - - // Prepare headers with external user ID - Map 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/AsyncWorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/AsyncWorkflowsClient.java deleted file mode 100644 index 08f9081..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/AsyncWorkflowsClient.java +++ /dev/null @@ -1,128 +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; -import java.util.concurrent.CompletableFuture; - -public class AsyncWorkflowsClient { - protected final ClientOptions clientOptions; - - private final AsyncRawWorkflowsClient rawClient; - - public AsyncWorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawWorkflowsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawWorkflowsClient 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 A future containing the response from the workflow - */ - public CompletableFuture invoke(String urlOrEndpoint) { - InvokeWorkflowOpts request = - InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build(); - return this.rawClient.invoke(request).thenApply(response -> response.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 A future containing the response from the workflow - */ - public CompletableFuture invoke(String urlOrEndpoint, RequestOptions requestOptions) { - InvokeWorkflowOpts request = - InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build(); - return this.rawClient.invoke(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow using the InvokeWorkflowOpts request object. - * - * @param request The request containing workflow invocation parameters - * @return A future containing the response from the workflow - */ - public CompletableFuture invoke(InvokeWorkflowOpts request) { - return this.rawClient.invoke(request).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow using the InvokeWorkflowOpts request object. - * - * @param request The request containing workflow invocation parameters - * @param requestOptions Additional request options - * @return A future containing the response from the workflow - */ - public CompletableFuture invoke(InvokeWorkflowOpts request, RequestOptions requestOptions) { - return this.rawClient.invoke(request, requestOptions).thenApply(response -> response.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 A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser(String urlOrEndpoint, String externalUserId) { - InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder() - .url(urlOrEndpoint) - .externalUserId(externalUserId) - .build(); - return this.rawClient.invokeForExternalUser(request).thenApply(response -> response.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 A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser( - String urlOrEndpoint, String externalUserId, RequestOptions requestOptions) { - InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder() - .url(urlOrEndpoint) - .externalUserId(externalUserId) - .build(); - return this.rawClient.invokeForExternalUser(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object. - * - * @param request The request containing workflow invocation parameters - * @return A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser(InvokeWorkflowForExternalUserOpts request) { - return this.rawClient.invokeForExternalUser(request).thenApply(response -> response.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 A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - return this.rawClient.invokeForExternalUser(request, requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java deleted file mode 100644 index f48397c..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows; - -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.MediaTypes; -import com.pipedream.api.core.ObjectMappers; -import com.pipedream.api.core.RequestOptions; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts; -import com.pipedream.api.types.HTTPAuthType; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawWorkflowsClient { - protected final ClientOptions clientOptions; - private final String workflowDomain; - private final String urlProtocol; - - public RawWorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.workflowDomain = getDefaultWorkflowDomain(); - this.urlProtocol = getUrlProtocol(); - } - - public BaseClientHttpResponse invoke(InvokeWorkflowOpts request) { - return invoke(request, null); - } - - public BaseClientHttpResponse invoke(InvokeWorkflowOpts request, RequestOptions requestOptions) { - // Build the workflow URL - String urlString = buildWorkflowUrl(request.getUrlOrEndpoint()); - - HttpUrl httpUrl; - try { - httpUrl = HttpUrl.parse(urlString); - if (httpUrl == null) { - throw new IllegalArgumentException("Invalid URL: " + urlString); - } - } catch (Exception e) { - throw new IllegalArgumentException("Invalid URL: " + urlString, e); - } - - // Determine auth type - default to OAuth if not specified - HTTPAuthType authType = request.getAuthType().orElse(HTTPAuthType.OAUTH); - - // Prepare headers - start with client options headers (includes OAuth auth if configured) - Map allHeaders = new HashMap<>(clientOptions.headers(requestOptions)); - - // Handle authentication based on type - if (authType == HTTPAuthType.OAUTH) { - // For OAuth, the Authorization header should already be in clientOptions.headers() - // No additional action needed - } else if (authType == HTTPAuthType.STATIC_BEARER) { - // For static_bearer, users must provide the Authorization header in request.getHeaders() - // Their header will override any existing OAuth header when we merge request headers - } else if (authType == HTTPAuthType.NONE) { - // For NONE auth type, set Authorization header to empty string (matches Python SDK) - allHeaders.put("Authorization", ""); - } - - // Add request-specific headers (can override auth headers for STATIC_BEARER) - if (request.getHeaders().isPresent()) { - allHeaders.putAll(request.getHeaders().get()); - } - - // Determine HTTP method - String method = request.getMethod().orElse("POST").toUpperCase(); - - // Prepare request body if needed - RequestBody body = null; - if (request.getBody().isPresent()) { - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes( - request.getBody().get()), - MediaTypes.APPLICATION_JSON); - allHeaders.put("Content-Type", "application/json"); - } catch (Exception e) { - throw new RuntimeException("Failed to serialize request body", e); - } - } else if (("POST".equals(method) || "PUT".equals(method) || "PATCH".equals(method))) { - // For methods that typically require a body, send an empty body - // to avoid OkHttp's "method POST must have a request body" error - body = RequestBody.create(new byte[0], null); - } - - // Build the request - Request.Builder requestBuilder = - new Request.Builder().url(httpUrl).method(method, body).headers(Headers.of(allHeaders)); - - if (!allHeaders.containsKey("Accept")) { - requestBuilder.addHeader("Accept", "application/json"); - } - - Request okhttpRequest = requestBuilder.build(); - - // Execute the request - 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()) { - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - Object parsedResponse; - try { - parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception e) { - // If JSON parsing fails, return the raw string - parsedResponse = responseBodyString; - } - return new BaseClientHttpResponse<>(parsedResponse, response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - 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); - } - } - - public BaseClientHttpResponse invokeForExternalUser(InvokeWorkflowForExternalUserOpts request) { - return invokeForExternalUser(request, null); - } - - public BaseClientHttpResponse invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - - // Validate inputs - if (request.getExternalUserId() == null - || request.getExternalUserId().trim().isEmpty()) { - throw new IllegalArgumentException("External user ID is required"); - } - - if (request.getUrl() == null || request.getUrl().trim().isEmpty()) { - throw new IllegalArgumentException("Workflow URL is required"); - } - - // Prepare headers with external user ID - Map 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 body; - - private final Optional> headers; - - private final Optional method; - - private final Optional authType; - - private InvokeWorkflowForExternalUserOpts( - String url, - String externalUserId, - Optional body, - Optional> headers, - Optional method, - Optional authType) { - this.url = url; - this.externalUserId = externalUserId; - this.body = body; - this.headers = headers; - this.method = method; - this.authType = authType; - } - - @JsonProperty("url") - public String getUrl() { - return url; - } - - @JsonProperty("externalUserId") - public String getExternalUserId() { - return externalUserId; - } - - @JsonProperty("body") - public Optional getBody() { - return body; - } - - @JsonProperty("headers") - public Optional> getHeaders() { - return headers; - } - - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - @JsonProperty("authType") - public Optional getAuthType() { - return authType; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvokeWorkflowForExternalUserOpts && equalTo((InvokeWorkflowForExternalUserOpts) other); - } - - private boolean equalTo(InvokeWorkflowForExternalUserOpts other) { - return url.equals(other.url) - && externalUserId.equals(other.externalUserId) - && body.equals(other.body) - && headers.equals(other.headers) - && method.equals(other.method) - && authType.equals(other.authType); - } - - @Override - public int hashCode() { - return Objects.hash(this.url, this.externalUserId, this.body, this.headers, this.method, this.authType); - } - - @Override - public String toString() { - return "InvokeWorkflowForExternalUserOpts{url: " + url + ", externalUserId: " + externalUserId + ", body: " - + body + ", headers: " + headers + ", method: " + method + ", authType: " + authType + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private String url; - - private String externalUserId; - - private Optional body = Optional.empty(); - - private Optional> headers = Optional.empty(); - - private Optional method = Optional.empty(); - - private Optional authType = Optional.empty(); - - private Builder() {} - - @JsonSetter("url") - public Builder url(String url) { - this.url = url; - return this; - } - - @JsonSetter("externalUserId") - public Builder externalUserId(String externalUserId) { - this.externalUserId = externalUserId; - return this; - } - - @JsonSetter(value = "body", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder body(Optional body) { - this.body = body; - return this; - } - - public Builder body(Object body) { - this.body = Optional.ofNullable(body); - return this; - } - - @JsonSetter(value = "headers", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder headers(Optional> headers) { - this.headers = headers; - return this; - } - - public Builder headers(Map headers) { - this.headers = Optional.ofNullable(headers); - return this; - } - - @JsonSetter(value = "method", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder method(Optional method) { - this.method = method; - return this; - } - - public Builder method(String method) { - this.method = Optional.ofNullable(method); - return this; - } - - @JsonSetter(value = "authType", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder authType(Optional authType) { - this.authType = authType; - return this; - } - - public Builder authType(HTTPAuthType authType) { - this.authType = Optional.ofNullable(authType); - return this; - } - - public InvokeWorkflowForExternalUserOpts build() { - return new InvokeWorkflowForExternalUserOpts(url, externalUserId, body, headers, method, authType); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java b/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java deleted file mode 100644 index 468d227..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java +++ /dev/null @@ -1,164 +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 = InvokeWorkflowOpts.Builder.class) -public final class InvokeWorkflowOpts { - private final String urlOrEndpoint; - - private final Optional body; - - private final Optional> headers; - - private final Optional method; - - private final Optional authType; - - private InvokeWorkflowOpts( - String urlOrEndpoint, - Optional body, - Optional> headers, - Optional method, - Optional authType) { - this.urlOrEndpoint = urlOrEndpoint; - this.body = body; - this.headers = headers; - this.method = method; - this.authType = authType; - } - - @JsonProperty("urlOrEndpoint") - public String getUrlOrEndpoint() { - return urlOrEndpoint; - } - - @JsonProperty("body") - public Optional getBody() { - return body; - } - - @JsonProperty("headers") - public Optional> getHeaders() { - return headers; - } - - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - @JsonProperty("authType") - public Optional getAuthType() { - return authType; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvokeWorkflowOpts && equalTo((InvokeWorkflowOpts) other); - } - - private boolean equalTo(InvokeWorkflowOpts other) { - return urlOrEndpoint.equals(other.urlOrEndpoint) - && body.equals(other.body) - && headers.equals(other.headers) - && method.equals(other.method) - && authType.equals(other.authType); - } - - @Override - public int hashCode() { - return Objects.hash(this.urlOrEndpoint, this.body, this.headers, this.method, this.authType); - } - - @Override - public String toString() { - return "InvokeWorkflowOpts{urlOrEndpoint: " + urlOrEndpoint + ", body: " + body + ", headers: " + headers - + ", method: " + method + ", authType: " + authType + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private String urlOrEndpoint; - - private Optional body = Optional.empty(); - - private Optional> headers = Optional.empty(); - - private Optional method = Optional.empty(); - - private Optional authType = Optional.empty(); - - private Builder() {} - - @JsonSetter("urlOrEndpoint") - public Builder urlOrEndpoint(String urlOrEndpoint) { - this.urlOrEndpoint = urlOrEndpoint; - return this; - } - - @JsonSetter(value = "body", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder body(Optional body) { - this.body = body; - return this; - } - - public Builder body(Object body) { - this.body = Optional.ofNullable(body); - return this; - } - - @JsonSetter(value = "headers", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder headers(Optional> headers) { - this.headers = headers; - return this; - } - - public Builder headers(Map headers) { - this.headers = Optional.ofNullable(headers); - return this; - } - - @JsonSetter(value = "method", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder method(Optional method) { - this.method = method; - return this; - } - - public Builder method(String method) { - this.method = Optional.ofNullable(method); - return this; - } - - @JsonSetter(value = "authType", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder authType(Optional authType) { - this.authType = authType; - return this; - } - - public Builder authType(HTTPAuthType authType) { - this.authType = Optional.ofNullable(authType); - return this; - } - - public InvokeWorkflowOpts build() { - return new InvokeWorkflowOpts(urlOrEndpoint, body, headers, method, authType); - } - } -}