Skip to content

Commit edd1b6d

Browse files
committed
Fix the Proxy logic
* Relax the response parsing logic since it's free-form * Take over the Proxy clients so that they expose a nicer interface
1 parent 20b2672 commit edd1b6d

File tree

6 files changed

+155
-110
lines changed

6 files changed

+155
-110
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ src/main/java/com/pipedream/api/PipedreamClient.java
1111
src/main/java/com/pipedream/api/PipedreamClientBuilder.java
1212
src/main/java/com/pipedream/api/AsyncPipedreamClient.java
1313
src/main/java/com/pipedream/api/AsyncPipedreamClientBuilder.java
14+
src/main/java/com/pipedream/api/resources/proxy/*
1415
src/main/java/com/pipedream/api/resources/workflows/*
1516
src/main/java/com/pipedream/api/types/HTTPAuthType.java

reference.md

Lines changed: 22 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@ client.projects().retrieveInfo("project_id");
22892289
</details>
22902290

22912291
## Proxy
2292-
<details><summary><code>client.proxy.get(projectId, url64) -> Object</code></summary>
2292+
<details><summary><code>client.proxy.get(url, request) -> Object</code></summary>
22932293
<dl>
22942294
<dd>
22952295

@@ -2303,8 +2303,7 @@ client.projects().retrieveInfo("project_id");
23032303

23042304
```java
23052305
client.proxy().get(
2306-
"project_id",
2307-
"url_64",
2306+
"https://api.example.com/endpoint",
23082307
ProxyGetRequest
23092308
.builder()
23102309
.externalUserId("external_user_id")
@@ -2325,15 +2324,7 @@ client.proxy().get(
23252324
<dl>
23262325
<dd>
23272326

2328-
**projectId:** `String` — The project ID, which starts with 'proj_'.
2329-
2330-
</dd>
2331-
</dl>
2332-
2333-
<dl>
2334-
<dd>
2335-
2336-
**url64:** `String` — Base64-encoded target URL
2327+
**url:** `String` — The target URL to proxy the request to
23372328

23382329
</dd>
23392330
</dl>
@@ -2356,12 +2347,19 @@ client.proxy().get(
23562347
</dd>
23572348
</dl>
23582349

2350+
#### 📄 Response
2351+
2352+
The proxy methods intelligently handle responses:
2353+
- **JSON responses**: Automatically parsed and returned as structured objects
2354+
- **Non-JSON responses**: Returned as raw strings (HTML, XML, plain text, etc.)
2355+
- **Empty responses**: Return `null`
2356+
23592357

23602358
</dd>
23612359
</dl>
23622360
</details>
23632361

2364-
<details><summary><code>client.proxy.post(projectId, url64, request) -> Object</code></summary>
2362+
<details><summary><code>client.proxy.post(url, request) -> Object</code></summary>
23652363
<dl>
23662364
<dd>
23672365

@@ -2375,8 +2373,7 @@ client.proxy().get(
23752373

23762374
```java
23772375
client.proxy().post(
2378-
"project_id",
2379-
"url_64",
2376+
"https://api.example.com/endpoint",
23802377
ProxyPostRequest
23812378
.builder()
23822379
.externalUserId("external_user_id")
@@ -2402,15 +2399,7 @@ client.proxy().post(
24022399
<dl>
24032400
<dd>
24042401

2405-
**projectId:** `String` — The project ID, which starts with 'proj_'.
2406-
2407-
</dd>
2408-
</dl>
2409-
2410-
<dl>
2411-
<dd>
2412-
2413-
**url64:** `String` — Base64-encoded target URL
2402+
**url:** `String` — The target URL to proxy the request to
24142403

24152404
</dd>
24162405
</dl>
@@ -2446,7 +2435,7 @@ client.proxy().post(
24462435
</dl>
24472436
</details>
24482437

2449-
<details><summary><code>client.proxy.put(projectId, url64, request) -> Object</code></summary>
2438+
<details><summary><code>client.proxy.put(url, request) -> Object</code></summary>
24502439
<dl>
24512440
<dd>
24522441

@@ -2460,8 +2449,7 @@ client.proxy().post(
24602449

24612450
```java
24622451
client.proxy().put(
2463-
"project_id",
2464-
"url_64",
2452+
"https://api.example.com/endpoint",
24652453
ProxyPutRequest
24662454
.builder()
24672455
.externalUserId("external_user_id")
@@ -2487,15 +2475,7 @@ client.proxy().put(
24872475
<dl>
24882476
<dd>
24892477

2490-
**projectId:** `String` — The project ID, which starts with 'proj_'.
2491-
2492-
</dd>
2493-
</dl>
2494-
2495-
<dl>
2496-
<dd>
2497-
2498-
**url64:** `String` — Base64-encoded target URL
2478+
**url:** `String` — The target URL to proxy the request to
24992479

25002480
</dd>
25012481
</dl>
@@ -2531,7 +2511,7 @@ client.proxy().put(
25312511
</dl>
25322512
</details>
25332513

2534-
<details><summary><code>client.proxy.delete(projectId, url64) -> Object</code></summary>
2514+
<details><summary><code>client.proxy.delete(url, request) -> Object</code></summary>
25352515
<dl>
25362516
<dd>
25372517

@@ -2545,8 +2525,7 @@ client.proxy().put(
25452525

25462526
```java
25472527
client.proxy().delete(
2548-
"project_id",
2549-
"url_64",
2528+
"https://api.example.com/endpoint",
25502529
ProxyDeleteRequest
25512530
.builder()
25522531
.externalUserId("external_user_id")
@@ -2567,15 +2546,7 @@ client.proxy().delete(
25672546
<dl>
25682547
<dd>
25692548

2570-
**projectId:** `String` — The project ID, which starts with 'proj_'.
2571-
2572-
</dd>
2573-
</dl>
2574-
2575-
<dl>
2576-
<dd>
2577-
2578-
**url64:** `String` — Base64-encoded target URL
2549+
**url:** `String` — The target URL to proxy the request to
25792550

25802551
</dd>
25812552
</dl>
@@ -2603,7 +2574,7 @@ client.proxy().delete(
26032574
</dl>
26042575
</details>
26052576

2606-
<details><summary><code>client.proxy.patch(projectId, url64, request) -> Object</code></summary>
2577+
<details><summary><code>client.proxy.patch(url, request) -> Object</code></summary>
26072578
<dl>
26082579
<dd>
26092580

@@ -2617,8 +2588,7 @@ client.proxy().delete(
26172588

26182589
```java
26192590
client.proxy().patch(
2620-
"project_id",
2621-
"url_64",
2591+
"https://api.example.com/endpoint",
26222592
ProxyPatchRequest
26232593
.builder()
26242594
.externalUserId("external_user_id")
@@ -2644,15 +2614,7 @@ client.proxy().patch(
26442614
<dl>
26452615
<dd>
26462616

2647-
**projectId:** `String` — The project ID, which starts with 'proj_'.
2648-
2649-
</dd>
2650-
</dl>
2651-
2652-
<dl>
2653-
<dd>
2654-
2655-
**url64:** `String` — Base64-encoded target URL
2617+
**url:** `String` — The target URL to proxy the request to
26562618

26572619
</dd>
26582620
</dl>

src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest;
1111
import com.pipedream.api.resources.proxy.requests.ProxyPostRequest;
1212
import com.pipedream.api.resources.proxy.requests.ProxyPutRequest;
13+
import java.util.Base64;
1314
import java.util.concurrent.CompletableFuture;
1415

1516
public class AsyncProxyClient {
@@ -29,43 +30,57 @@ public AsyncRawProxyClient withRawResponse() {
2930
return this.rawClient;
3031
}
3132

32-
public CompletableFuture<Object> get(String url64, ProxyGetRequest request) {
33+
private String encodeUrl(String url) {
34+
return Base64.getUrlEncoder().encodeToString(url.getBytes());
35+
}
36+
37+
public CompletableFuture<Object> get(String url, ProxyGetRequest request) {
38+
final String url64 = encodeUrl(url);
3339
return this.rawClient.get(url64, request).thenApply(response -> response.body());
3440
}
3541

36-
public CompletableFuture<Object> get(String url64, ProxyGetRequest request, RequestOptions requestOptions) {
42+
public CompletableFuture<Object> get(String url, ProxyGetRequest request, RequestOptions requestOptions) {
43+
final String url64 = encodeUrl(url);
3744
return this.rawClient.get(url64, request, requestOptions).thenApply(response -> response.body());
3845
}
3946

40-
public CompletableFuture<Object> post(String url64, ProxyPostRequest request) {
47+
public CompletableFuture<Object> post(String url, ProxyPostRequest request) {
48+
final String url64 = encodeUrl(url);
4149
return this.rawClient.post(url64, request).thenApply(response -> response.body());
4250
}
4351

44-
public CompletableFuture<Object> post(String url64, ProxyPostRequest request, RequestOptions requestOptions) {
52+
public CompletableFuture<Object> post(String url, ProxyPostRequest request, RequestOptions requestOptions) {
53+
final String url64 = encodeUrl(url);
4554
return this.rawClient.post(url64, request, requestOptions).thenApply(response -> response.body());
4655
}
4756

48-
public CompletableFuture<Object> put(String url64, ProxyPutRequest request) {
57+
public CompletableFuture<Object> put(String url, ProxyPutRequest request) {
58+
final String url64 = encodeUrl(url);
4959
return this.rawClient.put(url64, request).thenApply(response -> response.body());
5060
}
5161

52-
public CompletableFuture<Object> put(String url64, ProxyPutRequest request, RequestOptions requestOptions) {
62+
public CompletableFuture<Object> put(String url, ProxyPutRequest request, RequestOptions requestOptions) {
63+
final String url64 = encodeUrl(url);
5364
return this.rawClient.put(url64, request, requestOptions).thenApply(response -> response.body());
5465
}
5566

56-
public CompletableFuture<Object> delete(String url64, ProxyDeleteRequest request) {
67+
public CompletableFuture<Object> delete(String url, ProxyDeleteRequest request) {
68+
final String url64 = encodeUrl(url);
5769
return this.rawClient.delete(url64, request).thenApply(response -> response.body());
5870
}
5971

60-
public CompletableFuture<Object> delete(String url64, ProxyDeleteRequest request, RequestOptions requestOptions) {
72+
public CompletableFuture<Object> delete(String url, ProxyDeleteRequest request, RequestOptions requestOptions) {
73+
final String url64 = encodeUrl(url);
6174
return this.rawClient.delete(url64, request, requestOptions).thenApply(response -> response.body());
6275
}
6376

64-
public CompletableFuture<Object> patch(String url64, ProxyPatchRequest request) {
77+
public CompletableFuture<Object> patch(String url, ProxyPatchRequest request) {
78+
final String url64 = encodeUrl(url);
6579
return this.rawClient.patch(url64, request).thenApply(response -> response.body());
6680
}
6781

68-
public CompletableFuture<Object> patch(String url64, ProxyPatchRequest request, RequestOptions requestOptions) {
82+
public CompletableFuture<Object> patch(String url, ProxyPatchRequest request, RequestOptions requestOptions) {
83+
final String url64 = encodeUrl(url);
6984
return this.rawClient.patch(url64, request, requestOptions).thenApply(response -> response.body());
7085
}
7186
}

0 commit comments

Comments
 (0)