From 43263483e86f10fe5d1edfa2b4002dfbaf3d2414 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 02:26:30 +0000 Subject: [PATCH] SDK regeneration --- .fern/metadata.json | 13 ++ README.md | 59 +++++-- build.gradle | 13 +- .../com/pipedream/api/AsyncBaseClient.java | 19 +- .../java/com/pipedream/api/BaseClient.java | 19 +- .../api/core/BaseClientApiException.java | 4 +- .../com/pipedream/api/core/ClientOptions.java | 23 ++- .../api/core/NullableNonemptyFilter.java | 5 +- .../api/core/OAuthTokenSupplier.java | 6 +- .../com/pipedream/api/core/ObjectMappers.java | 9 + .../pipedream/api/core/RetryInterceptor.java | 118 ++++++++++++- .../api/core/pagination/AsyncCustomPager.java | 165 ++++++++++++++++++ .../core/pagination/BiDirectionalPage.java | 60 +++++++ .../api/core/pagination/CustomPager.java | 118 +++++++++++++ .../resources/accounts/AccountsClient.java | 14 ++ .../accounts/AsyncAccountsClient.java | 14 ++ .../accounts/AsyncRawAccountsClient.java | 57 +++--- .../resources/accounts/RawAccountsClient.java | 56 +++--- .../accounts/requests/CreateAccountOpts.java | 62 ++++++- .../api/resources/actions/ActionsClient.java | 14 ++ .../resources/actions/AsyncActionsClient.java | 14 ++ .../actions/AsyncRawActionsClient.java | 75 ++++---- .../resources/actions/RawActionsClient.java | 75 ++++---- .../AsyncRawAppCategoriesClient.java | 21 +-- .../appcategories/RawAppCategoriesClient.java | 20 +-- .../api/resources/apps/AppsClient.java | 7 + .../api/resources/apps/AsyncAppsClient.java | 7 + .../resources/apps/AsyncRawAppsClient.java | 27 +-- .../api/resources/apps/RawAppsClient.java | 27 +-- .../components/AsyncComponentsClient.java | 14 ++ .../components/AsyncRawComponentsClient.java | 62 ++++--- .../components/ComponentsClient.java | 14 ++ .../components/RawComponentsClient.java | 62 ++++--- .../AsyncRawDeployedTriggersClient.java | 108 +++++------- .../RawDeployedTriggersClient.java | 108 +++++------- .../filestash/AsyncRawFileStashClient.java | 9 +- .../filestash/RawFileStashClient.java | 9 +- .../AsyncRawOauthTokensClient.java | 11 +- .../oauthtokens/RawOauthTokensClient.java | 10 +- .../AsyncRawProjectEnvironmentClient.java | 39 ++--- .../RawProjectEnvironmentClient.java | 40 ++--- .../projects/AsyncProjectsClient.java | 14 ++ .../projects/AsyncRawProjectsClient.java | 79 ++++----- .../resources/projects/ProjectsClient.java | 14 ++ .../resources/projects/RawProjectsClient.java | 80 ++++----- .../tokens/AsyncRawTokensClient.java | 24 +-- .../api/resources/tokens/RawTokensClient.java | 26 ++- .../requests/TokensValidateRequest.java | 53 +++++- .../triggers/AsyncRawTriggersClient.java | 75 ++++---- .../triggers/AsyncTriggersClient.java | 14 ++ .../resources/triggers/RawTriggersClient.java | 75 ++++---- .../resources/triggers/TriggersClient.java | 14 ++ .../resources/usage/AsyncRawUsageClient.java | 10 +- .../api/resources/usage/RawUsageClient.java | 11 +- .../resources/users/AsyncRawUsersClient.java | 24 +-- .../api/resources/users/AsyncUsersClient.java | 7 + .../api/resources/users/RawUsersClient.java | 23 +-- .../api/resources/users/UsersClient.java | 7 + .../types/ConfigurablePropAirtableBaseId.java | 2 + .../ConfigurablePropAirtableFieldId.java | 2 + .../ConfigurablePropAirtableTableId.java | 2 + .../types/ConfigurablePropAirtableViewId.java | 2 + .../api/types/ConfigurablePropAlert.java | 2 + .../api/types/ConfigurablePropAny.java | 2 + .../api/types/ConfigurablePropApp.java | 2 + .../api/types/ConfigurablePropApphook.java | 2 + .../api/types/ConfigurablePropBase.java | 2 + .../api/types/ConfigurablePropBoolean.java | 2 + .../api/types/ConfigurablePropDataStore.java | 2 + .../api/types/ConfigurablePropDb.java | 2 + .../api/types/ConfigurablePropDir.java | 2 + .../api/types/ConfigurablePropDiscord.java | 2 + .../types/ConfigurablePropDiscordChannel.java | 2 + .../ConfigurablePropDiscordChannelArray.java | 2 + .../api/types/ConfigurablePropHttp.java | 2 + .../types/ConfigurablePropHttpRequest.java | 2 + .../api/types/ConfigurablePropInteger.java | 2 + .../types/ConfigurablePropIntegerArray.java | 2 + .../api/types/ConfigurablePropObject.java | 2 + .../api/types/ConfigurablePropSql.java | 2 + .../api/types/ConfigurablePropString.java | 2 + .../types/ConfigurablePropStringArray.java | 2 + .../api/types/ConfigurablePropTimer.java | 2 + .../java/com/pipedream/api/StreamTest.java | 23 ++- 84 files changed, 1549 insertions(+), 681 deletions(-) create mode 100644 .fern/metadata.json create mode 100644 src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java create mode 100644 src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java create mode 100644 src/main/java/com/pipedream/api/core/pagination/CustomPager.java diff --git a/.fern/metadata.json b/.fern/metadata.json new file mode 100644 index 0000000..0bafa0b --- /dev/null +++ b/.fern/metadata.json @@ -0,0 +1,13 @@ +{ + "cliVersion": "3.5.0", + "generatorName": "fernapi/fern-java-sdk", + "generatorVersion": "3.27.6", + "generatorConfig": { + "publish-to": "central", + "client-class-name": "BaseClient", + "custom-dependencies": [ + "api org.apache.commons:commons-text:1.13.1" + ] + }, + "sdkVersion": "1.1.14" +} \ No newline at end of file diff --git a/README.md b/README.md index cfa97c3..b5b3cc7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Add the dependency in your `build.gradle` file: ```groovy dependencies { - implementation 'com.pipedream:pipedream:1.1.13' + implementation 'com.pipedream:pipedream' } ``` @@ -40,7 +40,7 @@ Add the dependency in your `pom.xml` file: com.pipedream pipedream - 1.1.13 + 1.1.14 ``` @@ -56,12 +56,10 @@ import com.pipedream.api.resources.actions.requests.RunActionOpts; public class Example { public static void main(String[] args) { - BaseClient client = BaseClient - .builder() - .clientId("") - .clientSecret("") + BaseClient client = BaseClient.withCredentials("", "") .projectId("YOUR_PROJECT_ID") - .build(); + .build() + ; client.actions().run( RunActionOpts @@ -73,6 +71,29 @@ public class Example { } } ``` +## Authentication + +This SDK supports two authentication methods: + +### Option 1: Direct Bearer Token + +If you already have a valid access token, you can use it directly: + +```java +BaseClient client = BaseClient.withToken("your-access-token") + .url("https://api.example.com") + .build(); +``` + +### Option 2: OAuth Client Credentials + +The SDK can automatically handle token acquisition and refresh: + +```java +BaseClient client = BaseClient.withCredentials("client-id", "client-secret") + .url("https://api.example.com") + .build(); +``` ## Environments @@ -119,7 +140,7 @@ try{ ### Custom Client -This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one. +This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one. However, you can pass your own client like so: ```java @@ -138,7 +159,9 @@ BaseClient client = BaseClient The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured -retry limit (default: 2). +retry limit (default: 2). Before defaulting to exponential backoff, the SDK will first attempt to respect +the `Retry-After` header (as either in seconds or as an HTTP date), and then the `X-RateLimit-Reset` header +(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff. A request is deemed retryable when any of the following HTTP status codes is returned: @@ -160,7 +183,6 @@ BaseClient client = BaseClient ### Timeouts The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level. - ```java import com.pipedream.api.BaseClient; import com.pipedream.api.core.RequestOptions; @@ -168,7 +190,7 @@ import com.pipedream.api.core.RequestOptions; // Client level BaseClient client = BaseClient .builder() - .timeout(10) + .timeout(60) .build(); // Request level @@ -176,7 +198,7 @@ client.actions().run( ..., RequestOptions .builder() - .timeout(10) + .timeout(60) .build() ); ``` @@ -207,6 +229,19 @@ client.actions().run( ); ``` +### Access Raw Response Data + +The SDK provides access to raw response data, including headers, through the `withRawResponse()` method. +The `withRawResponse()` method returns a raw client that wraps all responses with `body()` and `headers()` methods. +(A normal client's `response` is identical to a raw client's `response.body()`.) + +```java +RunHttpResponse response = client.actions().withRawResponse().run(...); + +System.out.println(response.body()); +System.out.println(response.headers().get("X-My-Header")); +``` + ## Contributing While we value open-source contributions to this SDK, this library is generated programmatically. diff --git a/build.gradle b/build.gradle index 566b8cf..6855e46 100644 --- a/build.gradle +++ b/build.gradle @@ -14,15 +14,14 @@ repositories { } dependencies { - api 'com.squareup.okhttp3:okhttp:4.12.0' - api 'com.fasterxml.jackson.core:jackson-databind:2.17.2' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' + api 'com.squareup.okhttp3:okhttp:5.2.1' + api 'com.fasterxml.jackson.core:jackson-databind:2.18.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' api 'org.apache.commons:commons-text:1.13.1' - testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0' } @@ -49,7 +48,7 @@ java { group = 'com.pipedream' -version = '1.1.13' +version = '1.1.14' jar { dependsOn(":generatePomFileForMavenPublication") @@ -80,7 +79,7 @@ publishing { maven(MavenPublication) { groupId = 'com.pipedream' artifactId = 'pipedream' - version = '1.1.13' + version = '1.1.14' from components.java pom { name = 'pipedream' diff --git a/src/main/java/com/pipedream/api/AsyncBaseClient.java b/src/main/java/com/pipedream/api/AsyncBaseClient.java index 6495a30..3635ca6 100644 --- a/src/main/java/com/pipedream/api/AsyncBaseClient.java +++ b/src/main/java/com/pipedream/api/AsyncBaseClient.java @@ -134,7 +134,22 @@ public AsyncOauthTokensClient oauthTokens() { return this.oauthTokensClient.get(); } - public static AsyncBaseClientBuilder builder() { - return new AsyncBaseClientBuilder(); + /** + * Creates a client builder using a pre-generated access token. + * @param token The access token to use for authentication + * @return A builder configured for token authentication + */ + public static AsyncBaseClientBuilder._TokenAuth withToken(String token) { + return AsyncBaseClientBuilder.withToken(token); + } + + /** + * Creates a client builder using OAuth client credentials. + * @param clientId The OAuth client ID + * @param clientSecret The OAuth client secret + * @return A builder configured for OAuth authentication + */ + public static AsyncBaseClientBuilder._CredentialsAuth withCredentials(String clientId, String clientSecret) { + return AsyncBaseClientBuilder.withCredentials(clientId, clientSecret); } } diff --git a/src/main/java/com/pipedream/api/BaseClient.java b/src/main/java/com/pipedream/api/BaseClient.java index 361fe33..056a9f9 100644 --- a/src/main/java/com/pipedream/api/BaseClient.java +++ b/src/main/java/com/pipedream/api/BaseClient.java @@ -134,7 +134,22 @@ public OauthTokensClient oauthTokens() { return this.oauthTokensClient.get(); } - public static BaseClientBuilder builder() { - return new BaseClientBuilder(); + /** + * Creates a client builder using a pre-generated access token. + * @param token The access token to use for authentication + * @return A builder configured for token authentication + */ + public static BaseClientBuilder._TokenAuth withToken(String token) { + return BaseClientBuilder.withToken(token); + } + + /** + * Creates a client builder using OAuth client credentials. + * @param clientId The OAuth client ID + * @param clientSecret The OAuth client secret + * @return A builder configured for OAuth authentication + */ + public static BaseClientBuilder._CredentialsAuth withCredentials(String clientId, String clientSecret) { + return BaseClientBuilder.withCredentials(clientId, clientSecret); } } diff --git a/src/main/java/com/pipedream/api/core/BaseClientApiException.java b/src/main/java/com/pipedream/api/core/BaseClientApiException.java index a2680b0..f0e59f6 100644 --- a/src/main/java/com/pipedream/api/core/BaseClientApiException.java +++ b/src/main/java/com/pipedream/api/core/BaseClientApiException.java @@ -65,9 +65,9 @@ public Map> headers() { return this.headers; } - @java.lang.Override + @Override public String toString() { return "BaseClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " - + body + "}"; + + ObjectMappers.stringify(body) + "}"; } } diff --git a/src/main/java/com/pipedream/api/core/ClientOptions.java b/src/main/java/com/pipedream/api/core/ClientOptions.java index f9585df..65b9450 100644 --- a/src/main/java/com/pipedream/api/core/ClientOptions.java +++ b/src/main/java/com/pipedream/api/core/ClientOptions.java @@ -21,6 +21,8 @@ public final class ClientOptions { private final int timeout; + private final int maxRetries; + private String projectId; private ClientOptions( @@ -29,21 +31,23 @@ private ClientOptions( Map> headerSuppliers, OkHttpClient httpClient, int timeout, + int maxRetries, String projectId) { this.environment = environment; this.headers = new HashMap<>(); this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.pipedream:pipedream/1.1.13"); + put("User-Agent", "com.pipedream:pipedream/1.1.14"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.pipedream.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.1.13"); + put("X-Fern-SDK-Version", "1.1.14"); } }); this.headerSuppliers = headerSuppliers; this.httpClient = httpClient; this.timeout = timeout; + this.maxRetries = maxRetries; this.projectId = projectId; } @@ -86,6 +90,10 @@ public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { .build(); } + public int maxRetries() { + return this.maxRetries; + } + public String projectId() { return this.projectId; } @@ -181,7 +189,13 @@ public ClientOptions build() { this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); return new ClientOptions( - environment, headers, headerSuppliers, httpClient, this.timeout.get(), this.projectId); + environment, + headers, + headerSuppliers, + httpClient, + this.timeout.get(), + this.maxRetries, + this.projectId); } /** @@ -192,6 +206,9 @@ public static Builder from(ClientOptions clientOptions) { builder.environment = clientOptions.environment(); builder.timeout = Optional.of(clientOptions.timeout(null)); builder.httpClient = clientOptions.httpClient(); + builder.headers.putAll(clientOptions.headers); + builder.headerSuppliers.putAll(clientOptions.headerSuppliers); + builder.maxRetries = clientOptions.maxRetries(); builder.projectId = clientOptions.projectId(); return builder; } diff --git a/src/main/java/com/pipedream/api/core/NullableNonemptyFilter.java b/src/main/java/com/pipedream/api/core/NullableNonemptyFilter.java index afad6eb..c268e6e 100644 --- a/src/main/java/com/pipedream/api/core/NullableNonemptyFilter.java +++ b/src/main/java/com/pipedream/api/core/NullableNonemptyFilter.java @@ -14,6 +14,9 @@ public boolean equals(Object o) { } private boolean isOptionalEmpty(Object o) { - return o instanceof Optional && !((Optional) o).isPresent(); + if (o instanceof Optional) { + return !((Optional) o).isPresent(); + } + return false; } } diff --git a/src/main/java/com/pipedream/api/core/OAuthTokenSupplier.java b/src/main/java/com/pipedream/api/core/OAuthTokenSupplier.java index ddbde79..66c8adf 100644 --- a/src/main/java/com/pipedream/api/core/OAuthTokenSupplier.java +++ b/src/main/java/com/pipedream/api/core/OAuthTokenSupplier.java @@ -17,15 +17,18 @@ public final class OAuthTokenSupplier implements Supplier { private final String clientSecret; + private final String scope; + private final OauthTokensClient authClient; private String accessToken; private Instant expiresAt; - public OAuthTokenSupplier(String clientId, String clientSecret, OauthTokensClient authClient) { + public OAuthTokenSupplier(String clientId, String clientSecret, String scope, OauthTokensClient authClient) { this.clientId = clientId; this.clientSecret = clientSecret; + this.scope = scope; this.authClient = authClient; this.expiresAt = Instant.now(); } @@ -34,6 +37,7 @@ public CreateOAuthTokenResponse fetchToken() { CreateOAuthTokenOpts getTokenRequest = CreateOAuthTokenOpts.builder() .clientId(clientId) .clientSecret(clientSecret) + .scope(scope) .build(); return authClient.create(getTokenRequest); } diff --git a/src/main/java/com/pipedream/api/core/ObjectMappers.java b/src/main/java/com/pipedream/api/core/ObjectMappers.java index 6dd6c3c..aa3ba10 100644 --- a/src/main/java/com/pipedream/api/core/ObjectMappers.java +++ b/src/main/java/com/pipedream/api/core/ObjectMappers.java @@ -4,6 +4,7 @@ package com.pipedream.api.core; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -33,4 +34,12 @@ public static String stringify(Object o) { return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); } } + + public static Object parseErrorBody(String responseBodyString) { + try { + return JSON_MAPPER.readValue(responseBodyString, Object.class); + } catch (JsonProcessingException ignored) { + return responseBodyString; + } + } } diff --git a/src/main/java/com/pipedream/api/core/RetryInterceptor.java b/src/main/java/com/pipedream/api/core/RetryInterceptor.java index 66b6be4..da07beb 100644 --- a/src/main/java/com/pipedream/api/core/RetryInterceptor.java +++ b/src/main/java/com/pipedream/api/core/RetryInterceptor.java @@ -5,6 +5,9 @@ import java.io.IOException; import java.time.Duration; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Optional; import java.util.Random; import okhttp3.Interceptor; @@ -12,7 +15,10 @@ public class RetryInterceptor implements Interceptor { - private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private static final Duration INITIAL_RETRY_DELAY = Duration.ofMillis(1000); + private static final Duration MAX_RETRY_DELAY = Duration.ofMillis(60000); + private static final double JITTER_FACTOR = 0.2; + private final ExponentialBackoff backoff; private final Random random = new Random(); @@ -32,7 +38,7 @@ public Response intercept(Chain chain) throws IOException { } private Response retryChain(Response response, Chain chain) throws IOException { - Optional nextBackoff = this.backoff.nextBackoff(); + Optional nextBackoff = this.backoff.nextBackoff(response); while (nextBackoff.isPresent()) { try { Thread.sleep(nextBackoff.get().toMillis()); @@ -42,7 +48,7 @@ private Response retryChain(Response response, Chain chain) throws IOException { response.close(); response = chain.proceed(chain.request()); if (shouldRetry(response.code())) { - nextBackoff = this.backoff.nextBackoff(); + nextBackoff = this.backoff.nextBackoff(response); } else { return response; } @@ -51,6 +57,102 @@ private Response retryChain(Response response, Chain chain) throws IOException { return response; } + /** + * Calculates the retry delay from response headers, with fallback to exponential backoff. + * Priority: Retry-After > X-RateLimit-Reset > Exponential Backoff + */ + private Duration getRetryDelayFromHeaders(Response response, int retryAttempt) { + // Check for Retry-After header first (RFC 7231), with no jitter + String retryAfter = response.header("Retry-After"); + if (retryAfter != null) { + // Parse as number of seconds... + Optional secondsDelay = tryParseLong(retryAfter) + .map(seconds -> seconds * 1000) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (secondsDelay.isPresent()) { + return secondsDelay.get(); + } + + // ...or as an HTTP date; both are valid + Optional dateDelay = tryParseHttpDate(retryAfter) + .map(resetTime -> resetTime.toInstant().toEpochMilli() - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (dateDelay.isPresent()) { + return dateDelay.get(); + } + } + + // Then check for industry-standard X-RateLimit-Reset header, with positive jitter + String rateLimitReset = response.header("X-RateLimit-Reset"); + if (rateLimitReset != null) { + // Assume Unix timestamp in epoch seconds + Optional rateLimitDelay = tryParseLong(rateLimitReset) + .map(resetTimeSeconds -> (resetTimeSeconds * 1000) - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(this::addPositiveJitter) + .map(Duration::ofMillis); + if (rateLimitDelay.isPresent()) { + return rateLimitDelay.get(); + } + } + + // Fall back to exponential backoff, with symmetric jitter + long baseDelay = INITIAL_RETRY_DELAY.toMillis() * (1L << retryAttempt); // 2^retryAttempt + long cappedDelay = Math.min(baseDelay, MAX_RETRY_DELAY.toMillis()); + return Duration.ofMillis(addSymmetricJitter(cappedDelay)); + } + + /** + * Attempts to parse a string as a long, returning empty Optional on failure. + */ + private Optional tryParseLong(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(Long.parseLong(value)); + } catch (NumberFormatException e) { + return Optional.empty(); + } + } + + /** + * Attempts to parse a string as an HTTP date (RFC 1123), returning empty Optional on failure. + */ + private Optional tryParseHttpDate(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME)); + } catch (DateTimeParseException e) { + return Optional.empty(); + } + } + + /** + * Adds positive jitter (100-120% of original value) to prevent thundering herd. + * Used for X-RateLimit-Reset header delays. + */ + private long addPositiveJitter(long delayMs) { + double jitterMultiplier = 1.0 + (random.nextDouble() * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + + /** + * Adds symmetric jitter (90-110% of original value) to prevent thundering herd. + * Used for exponential backoff delays. + */ + private long addSymmetricJitter(long delayMs) { + double jitterMultiplier = 1.0 + ((random.nextDouble() - 0.5) * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + private static boolean shouldRetry(int statusCode) { return statusCode == 408 || statusCode == 429 || statusCode >= 500; } @@ -65,14 +167,14 @@ private final class ExponentialBackoff { this.maxNumRetries = maxNumRetries; } - public Optional nextBackoff() { - retryNumber += 1; - if (retryNumber > maxNumRetries) { + public Optional nextBackoff(Response response) { + if (retryNumber >= maxNumRetries) { return Optional.empty(); } - int upperBound = (int) Math.pow(2, retryNumber); - return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + Duration delay = getRetryDelayFromHeaders(response, retryNumber); + retryNumber += 1; + return Optional.of(delay); } } } diff --git a/src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java b/src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java new file mode 100644 index 0000000..40ba44c --- /dev/null +++ b/src/main/java/com/pipedream/api/core/pagination/AsyncCustomPager.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.core.pagination; + +import com.pipedream.api.core.ClientOptions; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +/** + * Skeleton implementation for custom asynchronous bidirectional pagination. + * + * THIS CLASS MUST BE IMPLEMENTED BY THE USER. + * + * This file is added to .fernignore and will not be regenerated. + * Replace this skeleton implementation with your custom async pagination logic + * that handles your API's specific pagination structure (e.g., HATEOAS links). + * + * Example implementation for HATEOAS-style async pagination: + *
{@code
+ * public class AsyncCustomPager implements BiDirectionalPage {
+ *     private final List items;
+ *     private final String nextUrl;
+ *     private final String previousUrl;
+ *     private final AsyncHttpClient client;
+ *
+ *     public AsyncCustomPager(Response response, AsyncHttpClient client, ...) {
+ *         this.items = response.getData();
+ *         this.nextUrl = response.getLinks().getNext();
+ *         this.previousUrl = response.getLinks().getPrevious();
+ *         // ... store other needed context
+ *     }
+ *
+ *     @Override
+ *     public boolean hasNext() {
+ *         return nextUrl != null;
+ *     }
+ *
+ *     @Override
+ *     public CompletableFuture> nextPageAsync() {
+ *         if (!hasNext()) {
+ *             CompletableFuture> future = new CompletableFuture<>();
+ *             future.completeExceptionally(new NoSuchElementException("No next page available"));
+ *             return future;
+ *         }
+ *         // Make async HTTP request to nextUrl
+ *         return client.getAsync(nextUrl)
+ *             .thenApply(response -> new AsyncCustomPager<>(response, client, ...));
+ *     }
+ *
+ *     // ... implement other methods
+ * }
+ * }
+ * + * @param The type of items in the page + */ +public class AsyncCustomPager implements BiDirectionalPage { + + /** + * Create an AsyncCustomPager from an initial response. + * + * @param initialResponse The first page response from the API + * @param clientOptions The client options containing HTTP client and other configuration + * @param requestOptions Request options for authentication, headers, etc. + * @return A CompletableFuture containing the new AsyncCustomPager instance + */ + public static CompletableFuture> createAsync( + Object initialResponse, ClientOptions clientOptions, Object requestOptions) { + throw new UnsupportedOperationException("AsyncCustomPager must be implemented. " + + "Please implement this class in core/AsyncCustomPager.java to define your async pagination logic. " + + "This file has been added to .fernignore and will not be overwritten. " + + "See the class documentation for implementation examples."); + } + + @Override + public boolean hasNext() { + throw new UnsupportedOperationException("AsyncCustomPager.hasNext() must be implemented. " + + "This method should return true if a next page is available."); + } + + @Override + public boolean hasPrevious() { + throw new UnsupportedOperationException("AsyncCustomPager.hasPrevious() must be implemented. " + + "This method should return true if a previous page is available."); + } + + /** + * Asynchronously fetch the next page. + * + * @return A CompletableFuture that completes with the next page + * @throws java.util.NoSuchElementException if no next page exists (wrapped in CompletableFuture) + */ + public CompletableFuture> nextPageAsync() { + CompletableFuture> future = new CompletableFuture<>(); + future.completeExceptionally( + new UnsupportedOperationException("AsyncCustomPager.nextPageAsync() must be implemented. " + + "This method should asynchronously fetch and return the next page of results.")); + return future; + } + + /** + * Asynchronously fetch the previous page. + * + * @return A CompletableFuture that completes with the previous page + * @throws java.util.NoSuchElementException if no previous page exists (wrapped in CompletableFuture) + */ + public CompletableFuture> previousPageAsync() { + CompletableFuture> future = new CompletableFuture<>(); + future.completeExceptionally( + new UnsupportedOperationException("AsyncCustomPager.previousPageAsync() must be implemented. " + + "This method should asynchronously fetch and return the previous page of results.")); + return future; + } + + @Override + public BiDirectionalPage nextPage() throws IOException { + throw new UnsupportedOperationException("AsyncCustomPager.nextPage() must be implemented. " + + "Consider using nextPageAsync() for async operations, or implement synchronous blocking version."); + } + + @Override + public BiDirectionalPage previousPage() throws IOException { + throw new UnsupportedOperationException( + "AsyncCustomPager.previousPage() must be implemented. " + + "Consider using previousPageAsync() for async operations, or implement synchronous blocking version."); + } + + @Override + public List getItems() { + throw new UnsupportedOperationException("AsyncCustomPager.getItems() must be implemented. " + + "This method should return the items in the current page."); + } + + @Override + public Optional getResponse() { + throw new UnsupportedOperationException("AsyncCustomPager.getResponse() must be implemented. " + + "This method should return the full response object for accessing pagination metadata."); + } + + /** + * Asynchronously iterate through all pages starting from current. + * Returns a CompletableFuture that completes with all items from all pages. + * + * @return CompletableFuture containing all items across all pages + */ + public CompletableFuture> getAllItemsAsync() { + throw new UnsupportedOperationException("AsyncCustomPager.getAllItemsAsync() must be implemented. " + + "This method should asynchronously fetch all pages and return all items."); + } + + /** + * Process each page asynchronously as it arrives. + * + * @param pageProcessor Function to process each page + * @return CompletableFuture that completes when all pages are processed + */ + public CompletableFuture forEachPageAsync( + java.util.function.Function, CompletionStage> pageProcessor) { + throw new UnsupportedOperationException("AsyncCustomPager.forEachPageAsync() must be implemented. " + + "This method should asynchronously process each page with the given function."); + } +} diff --git a/src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java b/src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java new file mode 100644 index 0000000..2d21d7c --- /dev/null +++ b/src/main/java/com/pipedream/api/core/pagination/BiDirectionalPage.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.core.pagination; + +import java.util.List; + +/** + * Interface for pages that support bidirectional pagination (both forward and backward navigation). + * This is used for custom pagination scenarios where the API provides both next and previous page links. + * + * @param The type of items in the page + */ +public interface BiDirectionalPage { + /** + * Returns whether there is a next page available. + * + * @return true if next page exists and can be fetched + */ + boolean hasNext(); + + /** + * Returns whether there is a previous page available. + * + * @return true if previous page exists and can be fetched + */ + boolean hasPrevious(); + + /** + * Fetches and returns the next page. + * + * @return the next page + * @throws java.util.NoSuchElementException if no next page exists + * @throws java.io.IOException if the HTTP request fails + */ + BiDirectionalPage nextPage() throws java.io.IOException; + + /** + * Fetches and returns the previous page. + * + * @return the previous page + * @throws java.util.NoSuchElementException if no previous page exists + * @throws java.io.IOException if the HTTP request fails + */ + BiDirectionalPage previousPage() throws java.io.IOException; + + /** + * Returns the items in the current page. + * + * @return list of items in this page + */ + List getItems(); + + /** + * Returns the full response object for accessing pagination metadata. + * + * @return Optional containing the response, or empty if unavailable + */ + java.util.Optional getResponse(); +} diff --git a/src/main/java/com/pipedream/api/core/pagination/CustomPager.java b/src/main/java/com/pipedream/api/core/pagination/CustomPager.java new file mode 100644 index 0000000..4397478 --- /dev/null +++ b/src/main/java/com/pipedream/api/core/pagination/CustomPager.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.core.pagination; + +import com.pipedream.api.core.ClientOptions; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; + +/** + * Skeleton implementation for custom bidirectional pagination. + * + * THIS CLASS MUST BE IMPLEMENTED BY THE USER. + * + * This file is added to .fernignore and will not be regenerated. + * Replace this skeleton implementation with your custom pagination logic + * that handles your API's specific pagination structure (e.g., HATEOAS links). + * + * Example implementation for HATEOAS-style pagination: + *
{@code
+ * public class CustomPager implements BiDirectionalPage, Iterable {
+ *     private final List items;
+ *     private final String nextUrl;
+ *     private final String previousUrl;
+ *     private final OkHttpClient client;
+ *     private final TypeReference> responseType;
+ *
+ *     public CustomPager(Response response, OkHttpClient client, ...) {
+ *         this.items = response.getData();
+ *         this.nextUrl = response.getLinks().getNext();
+ *         this.previousUrl = response.getLinks().getPrevious();
+ *         // ... store other needed context
+ *     }
+ *
+ *     @Override
+ *     public boolean hasNext() {
+ *         return nextUrl != null;
+ *     }
+ *
+ *     @Override
+ *     public CustomPager nextPage() throws IOException {
+ *         if (!hasNext()) {
+ *             throw new NoSuchElementException("No next page available");
+ *         }
+ *         // Make HTTP request to nextUrl
+ *         // Parse response
+ *         // Return new CustomPager instance
+ *     }
+ *
+ *     // ... implement other methods
+ * }
+ * }
+ * + * @param The type of items in the page + */ +public class CustomPager implements BiDirectionalPage, Iterable { + + /** + * Create a CustomPager from an initial response. + * + * @param initialResponse The first page response from the API + * @param clientOptions The client options containing HTTP client and other configuration + * @param requestOptions Request options for authentication, headers, etc. + * @return A new CustomPager instance + * @throws IOException if the request fails + */ + public static CustomPager create(Object initialResponse, ClientOptions clientOptions, Object requestOptions) + throws IOException { + throw new UnsupportedOperationException("CustomPager must be implemented. " + + "Please implement this class in core/CustomPager.java to define your pagination logic. " + + "This file has been added to .fernignore and will not be overwritten. " + + "See the class documentation for implementation examples."); + } + + @Override + public boolean hasNext() { + throw new UnsupportedOperationException("CustomPager.hasNext() must be implemented. " + + "This method should return true if a next page is available."); + } + + @Override + public boolean hasPrevious() { + throw new UnsupportedOperationException("CustomPager.hasPrevious() must be implemented. " + + "This method should return true if a previous page is available."); + } + + @Override + public BiDirectionalPage nextPage() throws IOException { + throw new UnsupportedOperationException("CustomPager.nextPage() must be implemented. " + + "This method should fetch and return the next page of results."); + } + + @Override + public BiDirectionalPage previousPage() throws IOException { + throw new UnsupportedOperationException("CustomPager.previousPage() must be implemented. " + + "This method should fetch and return the previous page of results."); + } + + @Override + public List getItems() { + throw new UnsupportedOperationException("CustomPager.getItems() must be implemented. " + + "This method should return the items in the current page."); + } + + @Override + public Optional getResponse() { + throw new UnsupportedOperationException("CustomPager.getResponse() must be implemented. " + + "This method should return the full response object for accessing pagination metadata."); + } + + @Override + public Iterator iterator() { + throw new UnsupportedOperationException("CustomPager.iterator() must be implemented. " + + "This method should return an iterator that traverses all items across all pages."); + } +} diff --git a/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java b/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java index 328225d..ecc6a18 100644 --- a/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java +++ b/src/main/java/com/pipedream/api/resources/accounts/AccountsClient.java @@ -35,6 +35,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * Retrieve all connected accounts for the project with optional filtering + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * Retrieve all connected accounts for the project with optional filtering */ @@ -70,6 +77,13 @@ public Account retrieve(String accountId) { return this.rawClient.retrieve(accountId).body(); } + /** + * Get the details for a specific connected account + */ + public Account retrieve(String accountId, RequestOptions requestOptions) { + return this.rawClient.retrieve(accountId, requestOptions).body(); + } + /** * Get the details for a specific connected account */ diff --git a/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java b/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java index da3e9be..26064b3 100644 --- a/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java +++ b/src/main/java/com/pipedream/api/resources/accounts/AsyncAccountsClient.java @@ -36,6 +36,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * Retrieve all connected accounts for the project with optional filtering + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * Retrieve all connected accounts for the project with optional filtering */ @@ -72,6 +79,13 @@ public CompletableFuture retrieve(String accountId) { return this.rawClient.retrieve(accountId).thenApply(response -> response.body()); } + /** + * Get the details for a specific connected account + */ + public CompletableFuture retrieve(String accountId, RequestOptions requestOptions) { + return this.rawClient.retrieve(accountId, requestOptions).thenApply(response -> response.body()); + } + /** * Get the details for a specific connected account */ diff --git a/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java b/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java index dd95b5f..487ea64 100644 --- a/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java +++ b/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java @@ -49,6 +49,13 @@ public CompletableFuture>> li return list(AccountsListRequest.builder().build()); } + /** + * Retrieve all connected accounts for the project with optional filtering + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + return list(AccountsListRequest.builder().build(), requestOptions); + } + /** * Retrieve all connected accounts for the project with optional filtering */ @@ -111,9 +118,10 @@ public CompletableFuture>> li @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ListAccountsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAccountsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAccountsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); AccountsListRequest nextRequest = AccountsListRequest.builder() @@ -135,7 +143,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -145,11 +152,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -212,12 +217,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -227,11 +232,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -253,6 +256,14 @@ public CompletableFuture> retrieve(String accoun return retrieve(accountId, AccountsRetrieveRequest.builder().build()); } + /** + * Get the details for a specific connected account + */ + public CompletableFuture> retrieve( + String accountId, RequestOptions requestOptions) { + return retrieve(accountId, AccountsRetrieveRequest.builder().build(), requestOptions); + } + /** * Get the details for a specific connected account */ @@ -294,12 +305,12 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -309,11 +320,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -375,11 +384,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -442,11 +449,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java b/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java index 777be36..46f6319 100644 --- a/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java +++ b/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java @@ -44,6 +44,13 @@ public BaseClientHttpResponse> list() { return list(AccountsListRequest.builder().build()); } + /** + * Retrieve all connected accounts for the project with optional filtering + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(AccountsListRequest.builder().build(), requestOptions); + } + /** * Retrieve all connected accounts for the project with optional filtering */ @@ -103,9 +110,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ListAccountsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAccountsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAccountsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); AccountsListRequest nextRequest = AccountsListRequest.builder() .from(request) @@ -118,7 +126,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -127,11 +134,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -181,11 +186,11 @@ public BaseClientHttpResponse create(CreateAccountOpts request, Request } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -194,11 +199,9 @@ public BaseClientHttpResponse create(CreateAccountOpts request, Request } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -211,6 +214,13 @@ public BaseClientHttpResponse retrieve(String accountId) { return retrieve(accountId, AccountsRetrieveRequest.builder().build()); } + /** + * Get the details for a specific connected account + */ + public BaseClientHttpResponse retrieve(String accountId, RequestOptions requestOptions) { + return retrieve(accountId, AccountsRetrieveRequest.builder().build(), requestOptions); + } + /** * Get the details for a specific connected account */ @@ -248,11 +258,11 @@ public BaseClientHttpResponse retrieve( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Account.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -261,11 +271,9 @@ public BaseClientHttpResponse retrieve( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -313,11 +321,9 @@ public BaseClientHttpResponse delete(String accountId, RequestOptions requ } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -366,11 +372,9 @@ public BaseClientHttpResponse deleteByApp(String appId, RequestOptions req } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountOpts.java b/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountOpts.java index d168d25..65bb755 100644 --- a/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountOpts.java +++ b/src/main/java/com/pipedream/api/resources/accounts/requests/CreateAccountOpts.java @@ -33,6 +33,8 @@ public final class CreateAccountOpts { private final Optional name; + private final Optional accountId; + private final Map additionalProperties; private CreateAccountOpts( @@ -42,6 +44,7 @@ private CreateAccountOpts( String cfmapJson, String connectToken, Optional name, + Optional accountId, Map additionalProperties) { this.externalUserId = externalUserId; this.oauthAppId = oauthAppId; @@ -49,6 +52,7 @@ private CreateAccountOpts( this.cfmapJson = cfmapJson; this.connectToken = connectToken; this.name = name; + this.accountId = accountId; this.additionalProperties = additionalProperties; } @@ -97,6 +101,14 @@ public Optional getName() { return name; } + /** + * @return An existing account ID to reconnect. When provided, the account's credentials are updated instead of creating a new account. Must belong to the same external user and project environment as the connect token, and match the app identified by app_slug. + */ + @JsonProperty("account_id") + public Optional getAccountId() { + return accountId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -114,13 +126,20 @@ private boolean equalTo(CreateAccountOpts other) { && appSlug.equals(other.appSlug) && cfmapJson.equals(other.cfmapJson) && connectToken.equals(other.connectToken) - && name.equals(other.name); + && name.equals(other.name) + && accountId.equals(other.accountId); } @java.lang.Override public int hashCode() { return Objects.hash( - this.externalUserId, this.oauthAppId, this.appSlug, this.cfmapJson, this.connectToken, this.name); + this.externalUserId, + this.oauthAppId, + this.appSlug, + this.cfmapJson, + this.connectToken, + this.name, + this.accountId); } @java.lang.Override @@ -175,6 +194,13 @@ public interface _FinalStage { _FinalStage name(Optional name); _FinalStage name(String name); + + /** + *

An existing account ID to reconnect. When provided, the account's credentials are updated instead of creating a new account. Must belong to the same external user and project environment as the connect token, and match the app identified by app_slug.

+ */ + _FinalStage accountId(Optional accountId); + + _FinalStage accountId(String accountId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -185,6 +211,8 @@ public static final class Builder implements AppSlugStage, CfmapJsonStage, Conne private String connectToken; + private Optional accountId = Optional.empty(); + private Optional name = Optional.empty(); private Optional oauthAppId = Optional.empty(); @@ -204,6 +232,7 @@ public Builder from(CreateAccountOpts other) { cfmapJson(other.getCfmapJson()); connectToken(other.getConnectToken()); name(other.getName()); + accountId(other.getAccountId()); return this; } @@ -243,6 +272,26 @@ public _FinalStage connectToken(@NotNull String connectToken) { return this; } + /** + *

An existing account ID to reconnect. When provided, the account's credentials are updated instead of creating a new account. Must belong to the same external user and project environment as the connect token, and match the app identified by app_slug.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage accountId(String accountId) { + this.accountId = Optional.ofNullable(accountId); + return this; + } + + /** + *

An existing account ID to reconnect. When provided, the account's credentials are updated instead of creating a new account. Must belong to the same external user and project environment as the connect token, and match the app identified by app_slug.

+ */ + @java.lang.Override + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) + public _FinalStage accountId(Optional accountId) { + this.accountId = accountId; + return this; + } + /** *

Optional name for the account

* @return Reference to {@code this} so that method calls can be chained together. @@ -299,7 +348,14 @@ public _FinalStage externalUserId(Optional externalUserId) { @java.lang.Override public CreateAccountOpts build() { return new CreateAccountOpts( - externalUserId, oauthAppId, appSlug, cfmapJson, connectToken, name, additionalProperties); + externalUserId, + oauthAppId, + appSlug, + cfmapJson, + connectToken, + name, + accountId, + additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/resources/actions/ActionsClient.java b/src/main/java/com/pipedream/api/resources/actions/ActionsClient.java index 18b750a..819dbed 100644 --- a/src/main/java/com/pipedream/api/resources/actions/ActionsClient.java +++ b/src/main/java/com/pipedream/api/resources/actions/ActionsClient.java @@ -40,6 +40,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * Retrieve available actions with optional search and app filtering + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * Retrieve available actions with optional search and app filtering */ @@ -61,6 +68,13 @@ public Component retrieve(String componentId) { return this.rawClient.retrieve(componentId).body(); } + /** + * Get detailed configuration for a specific action by its key + */ + public Component retrieve(String componentId, RequestOptions requestOptions) { + return this.rawClient.retrieve(componentId, requestOptions).body(); + } + /** * Get detailed configuration for a specific action by its key */ diff --git a/src/main/java/com/pipedream/api/resources/actions/AsyncActionsClient.java b/src/main/java/com/pipedream/api/resources/actions/AsyncActionsClient.java index 442f0b5..6f74724 100644 --- a/src/main/java/com/pipedream/api/resources/actions/AsyncActionsClient.java +++ b/src/main/java/com/pipedream/api/resources/actions/AsyncActionsClient.java @@ -41,6 +41,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * Retrieve available actions with optional search and app filtering + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * Retrieve available actions with optional search and app filtering */ @@ -63,6 +70,13 @@ public CompletableFuture retrieve(String componentId) { return this.rawClient.retrieve(componentId).thenApply(response -> response.body()); } + /** + * Get detailed configuration for a specific action by its key + */ + public CompletableFuture retrieve(String componentId, RequestOptions requestOptions) { + return this.rawClient.retrieve(componentId, requestOptions).thenApply(response -> response.body()); + } + /** * Get detailed configuration for a specific action by its key */ diff --git a/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java b/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java index db2d6db..4bcfac0 100644 --- a/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java +++ b/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java @@ -56,6 +56,14 @@ public CompletableFuture>> return list(ActionsListRequest.builder().build()); } + /** + * Retrieve available actions with optional search and app filtering + */ + public CompletableFuture>> list( + RequestOptions requestOptions) { + return list(ActionsListRequest.builder().build(), requestOptions); + } + /** * Retrieve available actions with optional search and app filtering */ @@ -110,9 +118,10 @@ public CompletableFuture>> @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); ActionsListRequest nextRequest = ActionsListRequest.builder() @@ -134,7 +143,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -151,11 +159,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -177,6 +183,14 @@ public CompletableFuture> retrieve(String comp return retrieve(componentId, ActionsRetrieveRequest.builder().build()); } + /** + * Get detailed configuration for a specific action by its key + */ + public CompletableFuture> retrieve( + String componentId, RequestOptions requestOptions) { + return retrieve(componentId, ActionsRetrieveRequest.builder().build(), requestOptions); + } + /** * Get detailed configuration for a specific action by its key */ @@ -215,13 +229,13 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -231,11 +245,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -266,7 +278,8 @@ public CompletableFuture> configur .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("actions/configure") + .addPathSegments("actions") + .addPathSegments("configure") .build(); RequestBody body; try { @@ -291,13 +304,13 @@ public CompletableFuture> configur @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -307,11 +320,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -342,7 +353,8 @@ public CompletableFuture> reloadProp .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("actions/props") + .addPathSegments("actions") + .addPathSegments("props") .build(); RequestBody body; try { @@ -367,13 +379,13 @@ public CompletableFuture> reloadProp @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -383,11 +395,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -418,7 +428,8 @@ public CompletableFuture> run( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("actions/run") + .addPathSegments("actions") + .addPathSegments("run") .build(); RequestBody body; try { @@ -443,13 +454,13 @@ public CompletableFuture> run( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RunActionResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, RunActionResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -459,11 +470,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java b/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java index 902614e..6058980 100644 --- a/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java +++ b/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java @@ -51,6 +51,13 @@ public BaseClientHttpResponse> list() { return list(ActionsListRequest.builder().build()); } + /** + * Retrieve available actions with optional search and app filtering + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(ActionsListRequest.builder().build(), requestOptions); + } + /** * Retrieve available actions with optional search and app filtering */ @@ -102,9 +109,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); ActionsListRequest nextRequest = ActionsListRequest.builder() .from(request) @@ -117,7 +125,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -130,11 +137,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -147,6 +152,13 @@ public BaseClientHttpResponse retrieve(String componentId) { return retrieve(componentId, ActionsRetrieveRequest.builder().build()); } + /** + * Get detailed configuration for a specific action by its key + */ + public BaseClientHttpResponse retrieve(String componentId, RequestOptions requestOptions) { + return retrieve(componentId, ActionsRetrieveRequest.builder().build(), requestOptions); + } + /** * Get detailed configuration for a specific action by its key */ @@ -181,12 +193,12 @@ public BaseClientHttpResponse retrieve( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -195,11 +207,9 @@ public BaseClientHttpResponse retrieve( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -221,7 +231,8 @@ public BaseClientHttpResponse configureProp( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("actions/configure") + .addPathSegments("actions") + .addPathSegments("configure") .build(); RequestBody body; try { @@ -243,12 +254,11 @@ public BaseClientHttpResponse configureProp( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -257,11 +267,9 @@ public BaseClientHttpResponse configureProp( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -283,7 +291,8 @@ public BaseClientHttpResponse reloadProps( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("actions/props") + .addPathSegments("actions") + .addPathSegments("props") .build(); RequestBody body; try { @@ -305,12 +314,11 @@ public BaseClientHttpResponse reloadProps( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -319,11 +327,9 @@ public BaseClientHttpResponse reloadProps( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -344,7 +350,8 @@ public BaseClientHttpResponse run(RunActionOpts request, Requ .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("actions/run") + .addPathSegments("actions") + .addPathSegments("run") .build(); RequestBody body; try { @@ -366,11 +373,11 @@ public BaseClientHttpResponse run(RunActionOpts request, Requ } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RunActionResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, RunActionResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -379,11 +386,9 @@ public BaseClientHttpResponse run(RunActionOpts request, Requ } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java b/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java index ea828f1..a8e5d04 100644 --- a/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java +++ b/src/main/java/com/pipedream/api/resources/appcategories/AsyncRawAppCategoriesClient.java @@ -61,19 +61,17 @@ public CompletableFuture>> list(Request @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}), + responseBodyString, new TypeReference>() {}), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -119,18 +117,15 @@ public CompletableFuture> retrieve(String id @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AppCategory.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AppCategory.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java b/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java index 401fd49..4a40980 100644 --- a/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java +++ b/src/main/java/com/pipedream/api/resources/appcategories/RawAppCategoriesClient.java @@ -54,18 +54,16 @@ public BaseClientHttpResponse> list(RequestOptions requestOpti } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}), + responseBodyString, new TypeReference>() {}), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -99,16 +97,14 @@ public BaseClientHttpResponse retrieve(String id, RequestOptions re } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AppCategory.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AppCategory.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/apps/AppsClient.java b/src/main/java/com/pipedream/api/resources/apps/AppsClient.java index 5e5fa6a..bae9766 100644 --- a/src/main/java/com/pipedream/api/resources/apps/AppsClient.java +++ b/src/main/java/com/pipedream/api/resources/apps/AppsClient.java @@ -34,6 +34,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * Retrieve all available apps with optional filtering and sorting + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * Retrieve all available apps with optional filtering and sorting */ diff --git a/src/main/java/com/pipedream/api/resources/apps/AsyncAppsClient.java b/src/main/java/com/pipedream/api/resources/apps/AsyncAppsClient.java index a573411..65257a4 100644 --- a/src/main/java/com/pipedream/api/resources/apps/AsyncAppsClient.java +++ b/src/main/java/com/pipedream/api/resources/apps/AsyncAppsClient.java @@ -35,6 +35,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * Retrieve all available apps with optional filtering and sorting + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * Retrieve all available apps with optional filtering and sorting */ diff --git a/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java b/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java index 63900eb..8daebda 100644 --- a/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java +++ b/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java @@ -44,6 +44,13 @@ public CompletableFuture>> list() return list(AppsListRequest.builder().build()); } + /** + * Retrieve all available apps with optional filtering and sorting + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + return list(AppsListRequest.builder().build(), requestOptions); + } + /** * Retrieve all available apps with optional filtering and sorting */ @@ -113,9 +120,10 @@ public CompletableFuture>> list( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ListAppsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAppsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAppsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); AppsListRequest nextRequest = AppsListRequest.builder() @@ -136,12 +144,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -188,18 +193,16 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetAppResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAppResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java b/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java index 403f724..5fe46dc 100644 --- a/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java +++ b/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java @@ -39,6 +39,13 @@ public BaseClientHttpResponse> list() { return list(AppsListRequest.builder().build()); } + /** + * Retrieve all available apps with optional filtering and sorting + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(AppsListRequest.builder().build(), requestOptions); + } + /** * Retrieve all available apps with optional filtering and sorting */ @@ -105,9 +112,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ListAppsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAppsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListAppsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); AppsListRequest nextRequest = AppsListRequest.builder() .from(request) @@ -120,12 +128,9 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -159,16 +164,14 @@ public BaseClientHttpResponse retrieve(String appId, RequestOpti } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetAppResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAppResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/components/AsyncComponentsClient.java b/src/main/java/com/pipedream/api/resources/components/AsyncComponentsClient.java index fabb8cc..e2383af 100644 --- a/src/main/java/com/pipedream/api/resources/components/AsyncComponentsClient.java +++ b/src/main/java/com/pipedream/api/resources/components/AsyncComponentsClient.java @@ -39,6 +39,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * Retrieve available components with optional search and app filtering + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * Retrieve available components with optional search and app filtering */ @@ -61,6 +68,13 @@ public CompletableFuture retrieve(String componentId) { return this.rawClient.retrieve(componentId).thenApply(response -> response.body()); } + /** + * Get detailed configuration for a specific component by its key + */ + public CompletableFuture retrieve(String componentId, RequestOptions requestOptions) { + return this.rawClient.retrieve(componentId, requestOptions).thenApply(response -> response.body()); + } + /** * Get detailed configuration for a specific component by its key */ diff --git a/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java b/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java index 7ad7e19..48e1c7a 100644 --- a/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java +++ b/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java @@ -54,6 +54,14 @@ public CompletableFuture>> return list(ComponentsListRequest.builder().build()); } + /** + * Retrieve available components with optional search and app filtering + */ + public CompletableFuture>> list( + RequestOptions requestOptions) { + return list(ComponentsListRequest.builder().build(), requestOptions); + } + /** * Retrieve available components with optional search and app filtering */ @@ -113,9 +121,10 @@ public CompletableFuture>> @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); ComponentsListRequest nextRequest = ComponentsListRequest.builder() @@ -137,7 +146,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -154,11 +162,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -180,6 +186,14 @@ public CompletableFuture> retrieve(String comp return retrieve(componentId, ComponentsRetrieveRequest.builder().build()); } + /** + * Get detailed configuration for a specific component by its key + */ + public CompletableFuture> retrieve( + String componentId, RequestOptions requestOptions) { + return retrieve(componentId, ComponentsRetrieveRequest.builder().build(), requestOptions); + } + /** * Get detailed configuration for a specific component by its key */ @@ -218,13 +232,13 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -234,11 +248,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -269,7 +281,8 @@ public CompletableFuture> configur .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("components/configure") + .addPathSegments("components") + .addPathSegments("configure") .build(); RequestBody body; try { @@ -294,13 +307,13 @@ public CompletableFuture> configur @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -310,11 +323,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -345,7 +356,8 @@ public CompletableFuture> reloadProp .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("components/props") + .addPathSegments("components") + .addPathSegments("props") .build(); RequestBody body; try { @@ -370,13 +382,13 @@ public CompletableFuture> reloadProp @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -386,11 +398,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/components/ComponentsClient.java b/src/main/java/com/pipedream/api/resources/components/ComponentsClient.java index 892f803..38f30c3 100644 --- a/src/main/java/com/pipedream/api/resources/components/ComponentsClient.java +++ b/src/main/java/com/pipedream/api/resources/components/ComponentsClient.java @@ -38,6 +38,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * Retrieve available components with optional search and app filtering + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * Retrieve available components with optional search and app filtering */ @@ -59,6 +66,13 @@ public Component retrieve(String componentId) { return this.rawClient.retrieve(componentId).body(); } + /** + * Get detailed configuration for a specific component by its key + */ + public Component retrieve(String componentId, RequestOptions requestOptions) { + return this.rawClient.retrieve(componentId, requestOptions).body(); + } + /** * Get detailed configuration for a specific component by its key */ diff --git a/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java b/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java index b5a237f..5de61dc 100644 --- a/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java +++ b/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java @@ -49,6 +49,13 @@ public BaseClientHttpResponse> list() { return list(ComponentsListRequest.builder().build()); } + /** + * Retrieve available components with optional search and app filtering + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(ComponentsListRequest.builder().build(), requestOptions); + } + /** * Retrieve available components with optional search and app filtering */ @@ -104,9 +111,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); ComponentsListRequest nextRequest = ComponentsListRequest.builder() .from(request) @@ -119,7 +127,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -132,11 +139,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -149,6 +154,13 @@ public BaseClientHttpResponse retrieve(String componentId) { return retrieve(componentId, ComponentsRetrieveRequest.builder().build()); } + /** + * Get detailed configuration for a specific component by its key + */ + public BaseClientHttpResponse retrieve(String componentId, RequestOptions requestOptions) { + return retrieve(componentId, ComponentsRetrieveRequest.builder().build(), requestOptions); + } + /** * Get detailed configuration for a specific component by its key */ @@ -183,12 +195,12 @@ public BaseClientHttpResponse retrieve( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -197,11 +209,9 @@ public BaseClientHttpResponse retrieve( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -223,7 +233,8 @@ public BaseClientHttpResponse configureProp( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("components/configure") + .addPathSegments("components") + .addPathSegments("configure") .build(); RequestBody body; try { @@ -245,12 +256,11 @@ public BaseClientHttpResponse configureProp( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -259,11 +269,9 @@ public BaseClientHttpResponse configureProp( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -285,7 +293,8 @@ public BaseClientHttpResponse reloadProps( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("components/props") + .addPathSegments("components") + .addPathSegments("props") .build(); RequestBody body; try { @@ -307,12 +316,11 @@ public BaseClientHttpResponse reloadProps( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -321,11 +329,9 @@ public BaseClientHttpResponse reloadProps( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java index faa8471..5fa7774 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java @@ -106,9 +106,10 @@ public CompletableFuture>> li @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggersResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggersResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggersResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); DeployedTriggersListRequest nextRequest = DeployedTriggersListRequest.builder() @@ -130,7 +131,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -140,11 +140,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -194,13 +192,13 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggerResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -210,11 +208,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -271,13 +267,13 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggerResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -287,11 +283,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -359,11 +353,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -417,13 +409,13 @@ public CompletableFuture>> listEvents( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - GetTriggerEventsResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetTriggerEventsResponse.class); + GetTriggerEventsResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerEventsResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -433,11 +425,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -488,14 +478,14 @@ public CompletableFuture> li @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetTriggerWorkflowsResponse.class), + responseBodyString, GetTriggerWorkflowsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -505,11 +495,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -568,14 +556,14 @@ public CompletableFuture> up @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetTriggerWorkflowsResponse.class), + responseBodyString, GetTriggerWorkflowsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -585,11 +573,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -640,14 +626,14 @@ public CompletableFuture> lis @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetTriggerWebhooksResponse.class), + responseBodyString, GetTriggerWebhooksResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -657,11 +643,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -720,14 +704,14 @@ public CompletableFuture> upd @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetTriggerWebhooksResponse.class), + responseBodyString, GetTriggerWebhooksResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -737,11 +721,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -796,14 +778,14 @@ public CompletableFuture( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetWebhookWithSigningKeyResponse.class), + responseBodyString, GetWebhookWithSigningKeyResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -813,11 +795,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -873,14 +853,14 @@ public CompletableFuture( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetWebhookWithSigningKeyResponse.class), + responseBodyString, GetWebhookWithSigningKeyResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -890,11 +870,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java index f88f7d5..6192257 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java @@ -97,9 +97,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggersResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggersResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggersResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); DeployedTriggersListRequest nextRequest = DeployedTriggersListRequest.builder() .from(request) @@ -112,7 +113,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -121,11 +121,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -162,12 +160,12 @@ public BaseClientHttpResponse retrieve( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggerResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -176,11 +174,9 @@ public BaseClientHttpResponse retrieve( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -225,12 +221,12 @@ public BaseClientHttpResponse update( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggerResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -239,11 +235,9 @@ public BaseClientHttpResponse update( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -296,11 +290,9 @@ public BaseClientHttpResponse delete( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -342,12 +334,12 @@ public BaseClientHttpResponse> listEvents( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetTriggerEventsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerEventsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerEventsResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -356,11 +348,9 @@ public BaseClientHttpResponse> listEvents( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -399,12 +389,12 @@ public BaseClientHttpResponse listWorkflows( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWorkflowsResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWorkflowsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -413,11 +403,9 @@ public BaseClientHttpResponse listWorkflows( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -464,12 +452,12 @@ public BaseClientHttpResponse updateWorkflows( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWorkflowsResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWorkflowsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -478,11 +466,9 @@ public BaseClientHttpResponse updateWorkflows( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -521,12 +507,12 @@ public BaseClientHttpResponse listWebhooks( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWebhooksResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWebhooksResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -535,11 +521,9 @@ public BaseClientHttpResponse listWebhooks( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -586,12 +570,12 @@ public BaseClientHttpResponse updateWebhooks( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTriggerWebhooksResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetTriggerWebhooksResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -600,11 +584,9 @@ public BaseClientHttpResponse updateWebhooks( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -647,13 +629,12 @@ public BaseClientHttpResponse retrieveWebhook( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetWebhookWithSigningKeyResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetWebhookWithSigningKeyResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -662,11 +643,9 @@ public BaseClientHttpResponse retrieveWebhook( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -710,13 +689,12 @@ public BaseClientHttpResponse regenerateWebhoo } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetWebhookWithSigningKeyResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetWebhookWithSigningKeyResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -725,11 +703,9 @@ public BaseClientHttpResponse regenerateWebhoo } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java b/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java index aa73f5d..af09992 100644 --- a/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java +++ b/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java @@ -50,7 +50,8 @@ public CompletableFuture> downloadFile( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("file_stash/download"); + .addPathSegments("file_stash") + .addPathSegments("download"); QueryStringMapper.addQueryParameter(httpUrl, "s3_key", request.getS3Key(), false); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) @@ -82,11 +83,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java b/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java index 2bd5052..e8dd8e7 100644 --- a/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java +++ b/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java @@ -46,7 +46,8 @@ public BaseClientHttpResponse downloadFile( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("file_stash/download"); + .addPathSegments("file_stash") + .addPathSegments("download"); QueryStringMapper.addQueryParameter(httpUrl, "s3_key", request.getS3Key(), false); Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) @@ -73,11 +74,9 @@ public BaseClientHttpResponse downloadFile( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java b/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java index a922464..1632abd 100644 --- a/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java +++ b/src/main/java/com/pipedream/api/resources/oauthtokens/AsyncRawOauthTokensClient.java @@ -72,19 +72,16 @@ public CompletableFuture> creat @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), CreateOAuthTokenResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateOAuthTokenResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java b/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java index 23a1d85..9e8e254 100644 --- a/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java +++ b/src/main/java/com/pipedream/api/resources/oauthtokens/RawOauthTokensClient.java @@ -65,17 +65,15 @@ public BaseClientHttpResponse create( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateOAuthTokenResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateOAuthTokenResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/projectenvironment/AsyncRawProjectEnvironmentClient.java b/src/main/java/com/pipedream/api/resources/projectenvironment/AsyncRawProjectEnvironmentClient.java index 8d67caa..c80c77d 100644 --- a/src/main/java/com/pipedream/api/resources/projectenvironment/AsyncRawProjectEnvironmentClient.java +++ b/src/main/java/com/pipedream/api/resources/projectenvironment/AsyncRawProjectEnvironmentClient.java @@ -69,13 +69,13 @@ public CompletableFuture> retrieveWeb @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetWebhookResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -85,11 +85,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -145,13 +143,13 @@ public CompletableFuture> updateWebho @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SetWebhookResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SetWebhookResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -161,11 +159,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -226,11 +222,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -261,7 +255,8 @@ public CompletableFuture( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetWebhookWithSigningKeyResponse.class), + responseBodyString, GetWebhookWithSigningKeyResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -295,11 +290,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/projectenvironment/RawProjectEnvironmentClient.java b/src/main/java/com/pipedream/api/resources/projectenvironment/RawProjectEnvironmentClient.java index 986b8c5..f4a31f2 100644 --- a/src/main/java/com/pipedream/api/resources/projectenvironment/RawProjectEnvironmentClient.java +++ b/src/main/java/com/pipedream/api/resources/projectenvironment/RawProjectEnvironmentClient.java @@ -61,11 +61,11 @@ public BaseClientHttpResponse retrieveWebhook(RequestOptions } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetWebhookResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -74,11 +74,9 @@ public BaseClientHttpResponse retrieveWebhook(RequestOptions } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -122,11 +120,11 @@ public BaseClientHttpResponse updateWebhook( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SetWebhookResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SetWebhookResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -135,11 +133,9 @@ public BaseClientHttpResponse updateWebhook( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -186,11 +182,9 @@ public BaseClientHttpResponse deleteWebhook(RequestOptions requestOptions) } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -212,7 +206,8 @@ public BaseClientHttpResponse regenerateWebhoo .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("webhook/regenerate_signing_key") + .addPathSegments("webhook") + .addPathSegments("regenerate_signing_key") .build(); Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -226,13 +221,12 @@ public BaseClientHttpResponse regenerateWebhoo } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetWebhookWithSigningKeyResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetWebhookWithSigningKeyResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -241,11 +235,9 @@ public BaseClientHttpResponse regenerateWebhoo } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/projects/AsyncProjectsClient.java b/src/main/java/com/pipedream/api/resources/projects/AsyncProjectsClient.java index 6f4eecf..245cb26 100644 --- a/src/main/java/com/pipedream/api/resources/projects/AsyncProjectsClient.java +++ b/src/main/java/com/pipedream/api/resources/projects/AsyncProjectsClient.java @@ -38,6 +38,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * List the projects that are available to the authenticated Connect client + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * List the projects that are available to the authenticated Connect client */ @@ -102,6 +109,13 @@ public CompletableFuture update(String projectId) { return this.rawClient.update(projectId).thenApply(response -> response.body()); } + /** + * Update project details or application information + */ + public CompletableFuture update(String projectId, RequestOptions requestOptions) { + return this.rawClient.update(projectId, requestOptions).thenApply(response -> response.body()); + } + /** * Update project details or application information */ diff --git a/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java b/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java index 2c9dffd..f820ab5 100644 --- a/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java +++ b/src/main/java/com/pipedream/api/resources/projects/AsyncRawProjectsClient.java @@ -53,6 +53,13 @@ public CompletableFuture>> li return list(ProjectsListRequest.builder().build()); } + /** + * List the projects that are available to the authenticated Connect client + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + return list(ProjectsListRequest.builder().build(), requestOptions); + } + /** * List the projects that are available to the authenticated Connect client */ @@ -98,9 +105,10 @@ public CompletableFuture>> li @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ListProjectsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListProjectsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListProjectsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); ProjectsListRequest nextRequest = ProjectsListRequest.builder() @@ -122,7 +130,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 404: @@ -139,11 +146,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -197,12 +202,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -212,11 +217,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -263,12 +266,12 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -278,11 +281,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -342,11 +343,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -368,6 +367,13 @@ public CompletableFuture> update(String projectI return update(projectId, UpdateProjectOpts.builder().build()); } + /** + * Update project details or application information + */ + public CompletableFuture> update(String projectId, RequestOptions requestOptions) { + return update(projectId, UpdateProjectOpts.builder().build(), requestOptions); + } + /** * Update project details or application information */ @@ -408,12 +414,12 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -423,11 +429,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -504,11 +508,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -538,7 +540,8 @@ public CompletableFuture> retrieveIn .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("projects/info") + .addPathSegments("projects") + .addPathSegments("info") .build(); Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -555,13 +558,13 @@ public CompletableFuture> retrieveIn @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProjectInfoResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProjectInfoResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -571,11 +574,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/projects/ProjectsClient.java b/src/main/java/com/pipedream/api/resources/projects/ProjectsClient.java index 709842b..dd5ced4 100644 --- a/src/main/java/com/pipedream/api/resources/projects/ProjectsClient.java +++ b/src/main/java/com/pipedream/api/resources/projects/ProjectsClient.java @@ -37,6 +37,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * List the projects that are available to the authenticated Connect client + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * List the projects that are available to the authenticated Connect client */ @@ -100,6 +107,13 @@ public Project update(String projectId) { return this.rawClient.update(projectId).body(); } + /** + * Update project details or application information + */ + public Project update(String projectId, RequestOptions requestOptions) { + return this.rawClient.update(projectId, requestOptions).body(); + } + /** * Update project details or application information */ diff --git a/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java b/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java index 2eee1a9..2f39241 100644 --- a/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java +++ b/src/main/java/com/pipedream/api/resources/projects/RawProjectsClient.java @@ -48,6 +48,13 @@ public BaseClientHttpResponse> list() { return list(ProjectsListRequest.builder().build()); } + /** + * List the projects that are available to the authenticated Connect client + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(ProjectsListRequest.builder().build(), requestOptions); + } + /** * List the projects that are available to the authenticated Connect client */ @@ -90,9 +97,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ListProjectsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListProjectsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListProjectsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); ProjectsListRequest nextRequest = ProjectsListRequest.builder() .from(request) @@ -105,7 +113,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 404: @@ -118,11 +125,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -163,11 +168,11 @@ public BaseClientHttpResponse create(CreateProjectOpts request, Request } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -176,11 +181,9 @@ public BaseClientHttpResponse create(CreateProjectOpts request, Request } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -214,11 +217,11 @@ public BaseClientHttpResponse retrieve(String projectId, RequestOptions } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -227,11 +230,9 @@ public BaseClientHttpResponse retrieve(String projectId, RequestOptions } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -277,11 +278,9 @@ public BaseClientHttpResponse delete(String projectId, RequestOptions requ } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -294,6 +293,13 @@ public BaseClientHttpResponse update(String projectId) { return update(projectId, UpdateProjectOpts.builder().build()); } + /** + * Update project details or application information + */ + public BaseClientHttpResponse update(String projectId, RequestOptions requestOptions) { + return update(projectId, UpdateProjectOpts.builder().build(), requestOptions); + } + /** * Update project details or application information */ @@ -331,11 +337,11 @@ public BaseClientHttpResponse update( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Project.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -344,11 +350,9 @@ public BaseClientHttpResponse update( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -408,11 +412,9 @@ public BaseClientHttpResponse updateLogo( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -433,7 +435,8 @@ public BaseClientHttpResponse retrieveInfo(RequestOptions r .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("projects/info") + .addPathSegments("projects") + .addPathSegments("info") .build(); Request okhttpRequest = new Request.Builder() .url(httpUrl) @@ -447,12 +450,11 @@ public BaseClientHttpResponse retrieveInfo(RequestOptions r } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProjectInfoResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ProjectInfoResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -461,11 +463,9 @@ public BaseClientHttpResponse retrieveInfo(RequestOptions r } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java b/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java index 5ab836b..e0042a5 100644 --- a/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java +++ b/src/main/java/com/pipedream/api/resources/tokens/AsyncRawTokensClient.java @@ -78,13 +78,13 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateTokenResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateTokenResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -94,11 +94,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -132,6 +130,10 @@ public CompletableFuture> validate .addPathSegment(ctok) .addPathSegments("validate"); QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } if (request.getOauthAppId().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "oauth_app_id", request.getOauthAppId().get(), false); @@ -151,13 +153,13 @@ public CompletableFuture> validate @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ValidateTokenResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidateTokenResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -167,11 +169,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java b/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java index f9414f5..75d2619 100644 --- a/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java +++ b/src/main/java/com/pipedream/api/resources/tokens/RawTokensClient.java @@ -70,12 +70,11 @@ public BaseClientHttpResponse create(CreateTokenOpts reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateTokenResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CreateTokenResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -84,11 +83,9 @@ public BaseClientHttpResponse create(CreateTokenOpts reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -112,6 +109,10 @@ public BaseClientHttpResponse validate( .addPathSegment(ctok) .addPathSegments("validate"); QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } if (request.getOauthAppId().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "oauth_app_id", request.getOauthAppId().get(), false); @@ -128,12 +129,11 @@ public BaseClientHttpResponse validate( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ValidateTokenResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidateTokenResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -142,11 +142,9 @@ public BaseClientHttpResponse validate( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/tokens/requests/TokensValidateRequest.java b/src/main/java/com/pipedream/api/resources/tokens/requests/TokensValidateRequest.java index dd18fed..db3617e 100644 --- a/src/main/java/com/pipedream/api/resources/tokens/requests/TokensValidateRequest.java +++ b/src/main/java/com/pipedream/api/resources/tokens/requests/TokensValidateRequest.java @@ -23,12 +23,19 @@ public final class TokensValidateRequest { private final String appId; + private final Optional accountId; + private final Optional oauthAppId; private final Map additionalProperties; - private TokensValidateRequest(String appId, Optional oauthAppId, Map additionalProperties) { + private TokensValidateRequest( + String appId, + Optional accountId, + Optional oauthAppId, + Map additionalProperties) { this.appId = appId; + this.accountId = accountId; this.oauthAppId = oauthAppId; this.additionalProperties = additionalProperties; } @@ -41,6 +48,14 @@ public String getAppId() { return appId; } + /** + * @return An existing account ID to reconnect. Must belong to the app identified by app_id. + */ + @JsonProperty("account_id") + public Optional getAccountId() { + return accountId; + } + /** * @return The OAuth app ID to validate against (if the token is for an OAuth app) */ @@ -61,12 +76,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(TokensValidateRequest other) { - return appId.equals(other.appId) && oauthAppId.equals(other.oauthAppId); + return appId.equals(other.appId) && accountId.equals(other.accountId) && oauthAppId.equals(other.oauthAppId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.appId, this.oauthAppId); + return Objects.hash(this.appId, this.accountId, this.oauthAppId); } @java.lang.Override @@ -90,6 +105,13 @@ public interface AppIdStage { public interface _FinalStage { TokensValidateRequest build(); + /** + *

An existing account ID to reconnect. Must belong to the app identified by app_id.

+ */ + _FinalStage accountId(Optional accountId); + + _FinalStage accountId(String accountId); + /** *

The OAuth app ID to validate against (if the token is for an OAuth app)

*/ @@ -104,6 +126,8 @@ public static final class Builder implements AppIdStage, _FinalStage { private Optional oauthAppId = Optional.empty(); + private Optional accountId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,6 +136,7 @@ private Builder() {} @java.lang.Override public Builder from(TokensValidateRequest other) { appId(other.getAppId()); + accountId(other.getAccountId()); oauthAppId(other.getOauthAppId()); return this; } @@ -148,9 +173,29 @@ public _FinalStage oauthAppId(Optional oauthAppId) { return this; } + /** + *

An existing account ID to reconnect. Must belong to the app identified by app_id.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage accountId(String accountId) { + this.accountId = Optional.ofNullable(accountId); + return this; + } + + /** + *

An existing account ID to reconnect. Must belong to the app identified by app_id.

+ */ + @java.lang.Override + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) + public _FinalStage accountId(Optional accountId) { + this.accountId = accountId; + return this; + } + @java.lang.Override public TokensValidateRequest build() { - return new TokensValidateRequest(appId, oauthAppId, additionalProperties); + return new TokensValidateRequest(appId, accountId, oauthAppId, additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java b/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java index 714501d..dff911a 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java @@ -57,6 +57,14 @@ public CompletableFuture>> return list(TriggersListRequest.builder().build()); } + /** + * Retrieve available triggers with optional search and app filtering + */ + public CompletableFuture>> list( + RequestOptions requestOptions) { + return list(TriggersListRequest.builder().build(), requestOptions); + } + /** * Retrieve available triggers with optional search and app filtering */ @@ -111,9 +119,10 @@ public CompletableFuture>> @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); TriggersListRequest nextRequest = TriggersListRequest.builder() @@ -135,7 +144,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -152,11 +160,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -178,6 +184,14 @@ public CompletableFuture> retrieve(String comp return retrieve(componentId, TriggersRetrieveRequest.builder().build()); } + /** + * Get detailed configuration for a specific trigger by its key + */ + public CompletableFuture> retrieve( + String componentId, RequestOptions requestOptions) { + return retrieve(componentId, TriggersRetrieveRequest.builder().build(), requestOptions); + } + /** * Get detailed configuration for a specific trigger by its key */ @@ -216,13 +230,13 @@ public CompletableFuture> retrieve( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -232,11 +246,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -267,7 +279,8 @@ public CompletableFuture> configur .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("triggers/configure") + .addPathSegments("triggers") + .addPathSegments("configure") .build(); RequestBody body; try { @@ -292,13 +305,13 @@ public CompletableFuture> configur @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -308,11 +321,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -343,7 +354,8 @@ public CompletableFuture> reloadProp .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("triggers/props") + .addPathSegments("triggers") + .addPathSegments("props") .build(); RequestBody body; try { @@ -368,13 +380,13 @@ public CompletableFuture> reloadProp @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -384,11 +396,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -419,7 +429,8 @@ public CompletableFuture> deploy( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("triggers/deploy") + .addPathSegments("triggers") + .addPathSegments("deploy") .build(); RequestBody body; try { @@ -444,13 +455,13 @@ public CompletableFuture> deploy( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { DeployTriggerResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeployTriggerResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeployTriggerResponse.class); future.complete(new BaseClientHttpResponse<>(parsedResponse.getData(), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -460,11 +471,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/triggers/AsyncTriggersClient.java b/src/main/java/com/pipedream/api/resources/triggers/AsyncTriggersClient.java index 9aa6e5e..c1c98c8 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/AsyncTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/triggers/AsyncTriggersClient.java @@ -41,6 +41,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * Retrieve available triggers with optional search and app filtering + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * Retrieve available triggers with optional search and app filtering */ @@ -63,6 +70,13 @@ public CompletableFuture retrieve(String componentId) { return this.rawClient.retrieve(componentId).thenApply(response -> response.body()); } + /** + * Get detailed configuration for a specific trigger by its key + */ + public CompletableFuture retrieve(String componentId, RequestOptions requestOptions) { + return this.rawClient.retrieve(componentId, requestOptions).thenApply(response -> response.body()); + } + /** * Get detailed configuration for a specific trigger by its key */ diff --git a/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java b/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java index 481ee85..30cdf0a 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java @@ -52,6 +52,13 @@ public BaseClientHttpResponse> list() { return list(TriggersListRequest.builder().build()); } + /** + * Retrieve available triggers with optional search and app filtering + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(TriggersListRequest.builder().build(), requestOptions); + } + /** * Retrieve available triggers with optional search and app filtering */ @@ -103,9 +110,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentsResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentsResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentsResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); TriggersListRequest nextRequest = TriggersListRequest.builder() .from(request) @@ -118,7 +126,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -131,11 +138,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -148,6 +153,13 @@ public BaseClientHttpResponse retrieve(String componentId) { return retrieve(componentId, TriggersRetrieveRequest.builder().build()); } + /** + * Get detailed configuration for a specific trigger by its key + */ + public BaseClientHttpResponse retrieve(String componentId, RequestOptions requestOptions) { + return retrieve(componentId, TriggersRetrieveRequest.builder().build(), requestOptions); + } + /** * Get detailed configuration for a specific trigger by its key */ @@ -182,12 +194,12 @@ public BaseClientHttpResponse retrieve( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetComponentResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetComponentResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -196,11 +208,9 @@ public BaseClientHttpResponse retrieve( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -222,7 +232,8 @@ public BaseClientHttpResponse configureProp( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("triggers/configure") + .addPathSegments("triggers") + .addPathSegments("configure") .build(); RequestBody body; try { @@ -244,12 +255,11 @@ public BaseClientHttpResponse configureProp( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConfigurePropResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConfigurePropResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -258,11 +268,9 @@ public BaseClientHttpResponse configureProp( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -284,7 +292,8 @@ public BaseClientHttpResponse reloadProps( .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("triggers/props") + .addPathSegments("triggers") + .addPathSegments("props") .build(); RequestBody body; try { @@ -306,12 +315,11 @@ public BaseClientHttpResponse reloadProps( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReloadPropsResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ReloadPropsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -320,11 +328,9 @@ public BaseClientHttpResponse reloadProps( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -345,7 +351,8 @@ public BaseClientHttpResponse deploy(DeployTriggerOpts request, Request .newBuilder() .addPathSegments("v1/connect") .addPathSegment(clientOptions.projectId()) - .addPathSegments("triggers/deploy") + .addPathSegments("triggers") + .addPathSegments("deploy") .build(); RequestBody body; try { @@ -367,12 +374,12 @@ public BaseClientHttpResponse deploy(DeployTriggerOpts request, Request } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { DeployTriggerResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeployTriggerResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeployTriggerResponse.class); return new BaseClientHttpResponse<>(parsedResponse.getData(), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -381,11 +388,9 @@ public BaseClientHttpResponse deploy(DeployTriggerOpts request, Request } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/triggers/TriggersClient.java b/src/main/java/com/pipedream/api/resources/triggers/TriggersClient.java index 04ee913..6c881bf 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/TriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/triggers/TriggersClient.java @@ -40,6 +40,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * Retrieve available triggers with optional search and app filtering + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * Retrieve available triggers with optional search and app filtering */ @@ -61,6 +68,13 @@ public Component retrieve(String componentId) { return this.rawClient.retrieve(componentId).body(); } + /** + * Get detailed configuration for a specific trigger by its key + */ + public Component retrieve(String componentId, RequestOptions requestOptions) { + return this.rawClient.retrieve(componentId, requestOptions).body(); + } + /** * Get detailed configuration for a specific trigger by its key */ diff --git a/src/main/java/com/pipedream/api/resources/usage/AsyncRawUsageClient.java b/src/main/java/com/pipedream/api/resources/usage/AsyncRawUsageClient.java index d1752bf..330c546 100644 --- a/src/main/java/com/pipedream/api/resources/usage/AsyncRawUsageClient.java +++ b/src/main/java/com/pipedream/api/resources/usage/AsyncRawUsageClient.java @@ -66,13 +66,13 @@ public CompletableFuture> list( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConnectUsageResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConnectUsageResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -89,11 +89,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/usage/RawUsageClient.java b/src/main/java/com/pipedream/api/resources/usage/RawUsageClient.java index 3bdb1a4..5c81186 100644 --- a/src/main/java/com/pipedream/api/resources/usage/RawUsageClient.java +++ b/src/main/java/com/pipedream/api/resources/usage/RawUsageClient.java @@ -58,12 +58,11 @@ public BaseClientHttpResponse list(UsageListRequest reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new BaseClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConnectUsageResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConnectUsageResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -76,11 +75,9 @@ public BaseClientHttpResponse list(UsageListRequest reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java b/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java index a56de82..6dc08a8 100644 --- a/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java +++ b/src/main/java/com/pipedream/api/resources/users/AsyncRawUsersClient.java @@ -86,11 +86,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); @@ -112,6 +110,14 @@ public CompletableFuture return list(UsersListRequest.builder().build()); } + /** + * Retrieve all external users for the project + */ + public CompletableFuture>> list( + RequestOptions requestOptions) { + return list(UsersListRequest.builder().build(), requestOptions); + } + /** * Retrieve all external users for the project */ @@ -159,9 +165,10 @@ public CompletableFuture @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetUsersResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetUsersResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetUsersResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); UsersListRequest nextRequest = UsersListRequest.builder() @@ -183,7 +190,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { future.completeExceptionally(new TooManyRequestsError( @@ -193,11 +199,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/pipedream/api/resources/users/AsyncUsersClient.java b/src/main/java/com/pipedream/api/resources/users/AsyncUsersClient.java index e40bc00..8123d94 100644 --- a/src/main/java/com/pipedream/api/resources/users/AsyncUsersClient.java +++ b/src/main/java/com/pipedream/api/resources/users/AsyncUsersClient.java @@ -48,6 +48,13 @@ public CompletableFuture> list() { return this.rawClient.list().thenApply(response -> response.body()); } + /** + * Retrieve all external users for the project + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + /** * Retrieve all external users for the project */ diff --git a/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java b/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java index ee2cc25..5a9d9ba 100644 --- a/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java +++ b/src/main/java/com/pipedream/api/resources/users/RawUsersClient.java @@ -75,11 +75,9 @@ public BaseClientHttpResponse deleteExternalUser(String externalUserId, Re } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } @@ -92,6 +90,13 @@ public BaseClientHttpResponse> list() { return list(UsersListRequest.builder().build()); } + /** + * Retrieve all external users for the project + */ + public BaseClientHttpResponse> list(RequestOptions requestOptions) { + return list(UsersListRequest.builder().build(), requestOptions); + } + /** * Retrieve all external users for the project */ @@ -136,9 +141,10 @@ public BaseClientHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { GetUsersResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetUsersResponse.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetUsersResponse.class); Optional startingAfter = parsedResponse.getPageInfo().getEndCursor(); UsersListRequest nextRequest = UsersListRequest.builder() .from(request) @@ -152,7 +158,6 @@ public BaseClientHttpResponse> list( .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 429) { throw new TooManyRequestsError( @@ -161,11 +166,9 @@ public BaseClientHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/pipedream/api/resources/users/UsersClient.java b/src/main/java/com/pipedream/api/resources/users/UsersClient.java index c79a0a2..551b264 100644 --- a/src/main/java/com/pipedream/api/resources/users/UsersClient.java +++ b/src/main/java/com/pipedream/api/resources/users/UsersClient.java @@ -47,6 +47,13 @@ public SyncPagingIterable list() { return this.rawClient.list().body(); } + /** + * Retrieve all external users for the project + */ + public SyncPagingIterable list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).body(); + } + /** * Retrieve all external users for the project */ diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableBaseId.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableBaseId.java index 0dccdad..148a438 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableBaseId.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableBaseId.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -402,6 +403,7 @@ public _FinalStage appProp(@NotNull String appProp) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableFieldId.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableFieldId.java index 477db0c..0cb592c 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableFieldId.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableFieldId.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -402,6 +403,7 @@ public _FinalStage tableIdProp(@NotNull String tableIdProp) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableTableId.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableTableId.java index a9de71a..17e2902 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableTableId.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableTableId.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -402,6 +403,7 @@ public _FinalStage baseIdProp(@NotNull String baseIdProp) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableViewId.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableViewId.java index 5fc4907..f572b52 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableViewId.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAirtableViewId.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -402,6 +403,7 @@ public _FinalStage tableIdProp(@NotNull String tableIdProp) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAlert.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAlert.java index 2585b1b..009a7b3 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAlert.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAlert.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -433,6 +434,7 @@ public _FinalStage alertType(Optional alertType) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java index 5c7358d..79db7ac 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -429,6 +430,7 @@ public _FinalStage default_(Optional default_) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropApp.java b/src/main/java/com/pipedream/api/types/ConfigurablePropApp.java index 7a78370..1bc611b 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropApp.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropApp.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -402,6 +403,7 @@ public _FinalStage app(@NotNull String app) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropApphook.java b/src/main/java/com/pipedream/api/types/ConfigurablePropApphook.java index 7f9eb88..dbad4ec 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropApphook.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropApphook.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -535,6 +536,7 @@ public _FinalStage eventNames(Optional> eventNames) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropBase.java b/src/main/java/com/pipedream/api/types/ConfigurablePropBase.java index 925e180..0018d58 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropBase.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropBase.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -366,6 +367,7 @@ public _FinalStage name(@NotNull String name) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java b/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java index e3cf143..cf3ffab 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -429,6 +430,7 @@ public _FinalStage default_(Optional default_) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropDataStore.java b/src/main/java/com/pipedream/api/types/ConfigurablePropDataStore.java index 6a20a2a..7924f17 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropDataStore.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropDataStore.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -366,6 +367,7 @@ public _FinalStage name(@NotNull String name) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropDb.java b/src/main/java/com/pipedream/api/types/ConfigurablePropDb.java index 55d3e79..60c182e 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropDb.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropDb.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -366,6 +367,7 @@ public _FinalStage name(@NotNull String name) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropDir.java b/src/main/java/com/pipedream/api/types/ConfigurablePropDir.java index 4db0c4a..4530d85 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropDir.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropDir.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -441,6 +442,7 @@ public _FinalStage accessMode(Optional accessMode * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropDiscord.java b/src/main/java/com/pipedream/api/types/ConfigurablePropDiscord.java index fb178e5..c9308a7 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropDiscord.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropDiscord.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -371,6 +372,7 @@ public _FinalStage name(@NotNull String name) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannel.java b/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannel.java index dcaa7d0..76d6505 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannel.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannel.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -402,6 +403,7 @@ public _FinalStage appProp(@NotNull String appProp) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannelArray.java b/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannelArray.java index 0f265f6..4ea19c8 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannelArray.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropDiscordChannelArray.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -411,6 +412,7 @@ public _FinalStage appProp(Optional appProp) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropHttp.java b/src/main/java/com/pipedream/api/types/ConfigurablePropHttp.java index 679a268..13803cc 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropHttp.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropHttp.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -410,6 +411,7 @@ public _FinalStage customResponse(Optional customResponse) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropHttpRequest.java b/src/main/java/com/pipedream/api/types/ConfigurablePropHttpRequest.java index bee1340..0e1f147 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropHttpRequest.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropHttpRequest.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -397,6 +398,7 @@ public _FinalStage default_(Optional default_) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java b/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java index 4454921..53c57c2 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -530,6 +531,7 @@ public _FinalStage min(Optional min) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArray.java b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArray.java index 2cbdfcf..3afb3b5 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArray.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArray.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -543,6 +544,7 @@ public _FinalStage min(Optional min) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java b/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java index 7266d78..f7b4fea 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -429,6 +430,7 @@ public _FinalStage default_(Optional> default_) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java b/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java index b395c53..b3e1eeb 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -460,6 +461,7 @@ public _FinalStage auth(Optional auth) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropString.java b/src/main/java/com/pipedream/api/types/ConfigurablePropString.java index 5f12b33..9dd14ea 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropString.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropString.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -504,6 +505,7 @@ public _FinalStage secret(Optional secret) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java b/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java index 1bd2b2e..17c874f 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -517,6 +518,7 @@ public _FinalStage secret(Optional secret) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropTimer.java b/src/main/java/com/pipedream/api/types/ConfigurablePropTimer.java index 286a4eb..7872013 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropTimer.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropTimer.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -473,6 +474,7 @@ public _FinalStage static_(Optional static_) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override + @JsonIgnore public _FinalStage withLabel(Boolean withLabel) { this.withLabel = Optional.ofNullable(withLabel); return this; diff --git a/src/test/java/com/pipedream/api/StreamTest.java b/src/test/java/com/pipedream/api/StreamTest.java index 57130cb..212816c 100644 --- a/src/test/java/com/pipedream/api/StreamTest.java +++ b/src/test/java/com/pipedream/api/StreamTest.java @@ -9,6 +9,9 @@ import com.pipedream.api.core.Stream; import java.io.IOException; import java.io.StringReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -17,8 +20,9 @@ public final class StreamTest { @Test public void testJsonStream() { - List messages = List.of(Map.of("message", "hello"), Map.of("message", "world")); - List jsonStrings = messages.stream().map(StreamTest::mapToJson).collect(Collectors.toList()); + List> messages = + Arrays.asList(createMap("message", "hello"), createMap("message", "world")); + List jsonStrings = messages.stream().map(StreamTest::mapToJson).collect(Collectors.toList()); String input = String.join("\n", jsonStrings); StringReader jsonInput = new StringReader(input); Stream jsonStream = Stream.fromJson(Map.class, jsonInput); @@ -33,8 +37,8 @@ public void testJsonStream() { @Test public void testSseStream() { - List events = List.of(Map.of("event", "start"), Map.of("event", "end")); - List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); + List> events = Arrays.asList(createMap("event", "start"), createMap("event", "end")); + List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); String input = String.join("\n" + "\n", sseStrings); StringReader sseInput = new StringReader(input); Stream sseStream = Stream.fromSse(Map.class, sseInput); @@ -49,8 +53,9 @@ public void testSseStream() { @Test public void testSseStreamWithTerminator() { - List events = List.of(Map.of("message", "first"), Map.of("message", "second")); - List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); + List> events = Arrays.asList(createMap("message", "first"), createMap("message", "second")); + List sseStrings = + new ArrayList<>(events.stream().map(StreamTest::mapToSse).collect(Collectors.toList())); sseStrings.add("data: [DONE]"); String input = String.join("\n" + "\n", sseStrings); StringReader sseInput = new StringReader(input); @@ -83,4 +88,10 @@ private static String mapToJson(Map map) { private static String mapToSse(Map map) { return "data: " + mapToJson(map); } + + private static Map createMap(String key, String value) { + Map map = new HashMap<>(); + map.put(key, value); + return map; + } }