diff --git a/README.md b/README.md index 8516429..23eb2cd 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Add the dependency in your `pom.xml` file: com.pipedream pipedream - 1.0.5 + 1.0.6 ``` @@ -45,10 +45,10 @@ public class Example { .builder() .clientId("") .clientSecret("") + .projectId("YOUR_PROJECT_ID") .build(); client.actions().run( - "project_id", RunActionOpts .builder() .id("id") @@ -93,9 +93,9 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc ```java import com.pipedream.api.core.PipedreamApiApiException; -try { +try{ client.actions().run(...); -} catch (PipedreamApiApiException e) { +} catch (PipedreamApiApiException e){ // Do something with the API exception... } ``` diff --git a/build.gradle b/build.gradle index e8564b2..6faa059 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,7 @@ dependencies { 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' } @@ -48,7 +49,7 @@ java { group = 'com.pipedream' -version = '1.0.5' +version = '1.0.6' jar { dependsOn(":generatePomFileForMavenPublication") @@ -79,7 +80,7 @@ publishing { maven(MavenPublication) { groupId = 'com.pipedream' artifactId = 'pipedream' - version = '1.0.5' + version = '1.0.6' 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 39ecdab..2e3976e 100644 --- a/src/main/java/com/pipedream/api/AsyncBaseClient.java +++ b/src/main/java/com/pipedream/api/AsyncBaseClient.java @@ -11,6 +11,7 @@ import com.pipedream.api.resources.apps.AsyncAppsClient; import com.pipedream.api.resources.components.AsyncComponentsClient; import com.pipedream.api.resources.deployedtriggers.AsyncDeployedTriggersClient; +import com.pipedream.api.resources.filestash.AsyncFileStashClient; import com.pipedream.api.resources.oauthtokens.AsyncOauthTokensClient; import com.pipedream.api.resources.projects.AsyncProjectsClient; import com.pipedream.api.resources.proxy.AsyncProxyClient; @@ -40,6 +41,8 @@ public class AsyncBaseClient { protected final Supplier projectsClient; + protected final Supplier fileStashClient; + protected final Supplier proxyClient; protected final Supplier tokensClient; @@ -57,6 +60,7 @@ public AsyncBaseClient(ClientOptions clientOptions) { this.triggersClient = Suppliers.memoize(() -> new AsyncTriggersClient(clientOptions)); this.deployedTriggersClient = Suppliers.memoize(() -> new AsyncDeployedTriggersClient(clientOptions)); this.projectsClient = Suppliers.memoize(() -> new AsyncProjectsClient(clientOptions)); + this.fileStashClient = Suppliers.memoize(() -> new AsyncFileStashClient(clientOptions)); this.proxyClient = Suppliers.memoize(() -> new AsyncProxyClient(clientOptions)); this.tokensClient = Suppliers.memoize(() -> new AsyncTokensClient(clientOptions)); this.oauthTokensClient = Suppliers.memoize(() -> new AsyncOauthTokensClient(clientOptions)); @@ -98,6 +102,10 @@ public AsyncProjectsClient projects() { return this.projectsClient.get(); } + public AsyncFileStashClient fileStash() { + return this.fileStashClient.get(); + } + public AsyncProxyClient proxy() { return this.proxyClient.get(); } diff --git a/src/main/java/com/pipedream/api/AsyncBaseClientBuilder.java b/src/main/java/com/pipedream/api/AsyncBaseClientBuilder.java index cc6e4a9..9989d86 100644 --- a/src/main/java/com/pipedream/api/AsyncBaseClientBuilder.java +++ b/src/main/java/com/pipedream/api/AsyncBaseClientBuilder.java @@ -7,14 +7,18 @@ import com.pipedream.api.core.Environment; import com.pipedream.api.core.OAuthTokenSupplier; import com.pipedream.api.resources.oauthtokens.OauthTokensClient; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import okhttp3.OkHttpClient; -public class AsyncBaseClientBuilder> { +public class AsyncBaseClientBuilder { private Optional timeout = Optional.empty(); private Optional maxRetries = Optional.empty(); + private final Map customHeaders = new HashMap<>(); + private String clientId = System.getenv("PIPEDREAM_CLIENT_ID"); private String clientSecret = System.getenv("PIPEDREAM_CLIENT_SECRET"); @@ -25,72 +29,84 @@ public class AsyncBaseClientBuilder> { private OkHttpClient httpClient; + private String projectId; + /** * Sets clientId. * Defaults to the PIPEDREAM_CLIENT_ID environment variable. */ - @SuppressWarnings("unchecked") - public T clientId(String clientId) { + public AsyncBaseClientBuilder clientId(String clientId) { this.clientId = clientId; - return (T) this; + return this; } /** * Sets clientSecret. * Defaults to the PIPEDREAM_CLIENT_SECRET environment variable. */ - @SuppressWarnings("unchecked") - public T clientSecret(String clientSecret) { + public AsyncBaseClientBuilder clientSecret(String clientSecret) { this.clientSecret = clientSecret; - return (T) this; + return this; } /** * Sets projectEnvironment */ - @SuppressWarnings("unchecked") - public T projectEnvironment(String projectEnvironment) { + public AsyncBaseClientBuilder projectEnvironment(String projectEnvironment) { this.projectEnvironment = projectEnvironment; - return (T) this; + return this; } - @SuppressWarnings("unchecked") - public T environment(Environment environment) { + public AsyncBaseClientBuilder environment(Environment environment) { this.environment = environment; - return (T) this; + return this; } - @SuppressWarnings("unchecked") - public T url(String url) { + public AsyncBaseClientBuilder url(String url) { this.environment = Environment.custom(url); - return (T) this; + return this; } /** * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. */ - @SuppressWarnings("unchecked") - public T timeout(int timeout) { + public AsyncBaseClientBuilder timeout(int timeout) { this.timeout = Optional.of(timeout); - return (T) this; + return this; } /** * Sets the maximum number of retries for the client. Defaults to 2 retries. */ - @SuppressWarnings("unchecked") - public T maxRetries(int maxRetries) { + public AsyncBaseClientBuilder maxRetries(int maxRetries) { this.maxRetries = Optional.of(maxRetries); - return (T) this; + return this; } /** * Sets the underlying OkHttp client */ - @SuppressWarnings("unchecked") - public T httpClient(OkHttpClient httpClient) { + public AsyncBaseClientBuilder httpClient(OkHttpClient httpClient) { this.httpClient = httpClient; - return (T) this; + return this; + } + + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public AsyncBaseClientBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + public AsyncBaseClientBuilder projectId(String projectId) { + this.projectId = projectId; + return this; } protected ClientOptions buildClientOptions() { @@ -102,6 +118,9 @@ protected ClientOptions buildClientOptions() { setHttpClient(builder); setTimeouts(builder); setRetries(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } setAdditional(builder); return builder.build(); } @@ -124,7 +143,7 @@ protected void setEnvironment(ClientOptions.Builder builder) { * * Example: *
{@code
-     * @Override
+     * @Override
      * protected void setAuthentication(ClientOptions.Builder builder) {
      *     super.setAuthentication(builder); // Keep existing auth
      *     builder.addHeader("X-API-Key", this.apiKey);
@@ -133,8 +152,12 @@ protected void setEnvironment(ClientOptions.Builder builder) {
      */
     protected void setAuthentication(ClientOptions.Builder builder) {
         if (this.clientId != null && this.clientSecret != null) {
-            OauthTokensClient authClient = new OauthTokensClient(
-                    ClientOptions.builder().environment(this.environment).build());
+            ClientOptions.Builder authClientOptionsBuilder =
+                    ClientOptions.builder().environment(this.environment);
+            if (this.projectId != null) {
+                authClientOptionsBuilder.projectId(this.projectId);
+            }
+            OauthTokensClient authClient = new OauthTokensClient(authClientOptionsBuilder.build());
             OAuthTokenSupplier oAuthTokenSupplier =
                     new OAuthTokenSupplier(this.clientId, this.clientSecret, authClient);
             builder.addHeader("Authorization", oAuthTokenSupplier);
@@ -149,7 +172,7 @@ protected void setAuthentication(ClientOptions.Builder builder) {
      *
      * Example:
      * 
{@code
-     * @Override
+     * @Override
      * protected void setCustomHeaders(ClientOptions.Builder builder) {
      *     super.setCustomHeaders(builder); // Keep existing headers
      *     builder.addHeader("X-Trace-ID", generateTraceId());
@@ -168,7 +191,11 @@ protected void setCustomHeaders(ClientOptions.Builder builder) {
      *
      * @param builder The ClientOptions.Builder to configure
      */
-    protected void setVariables(ClientOptions.Builder builder) {}
+    protected void setVariables(ClientOptions.Builder builder) {
+        if (this.projectId != null) {
+            builder.projectId(this.projectId);
+        }
+    }
 
     /**
      * Sets the request timeout configuration.
@@ -215,9 +242,9 @@ protected void setHttpClient(ClientOptions.Builder builder) {
      *
      * Example:
      * 
{@code
-     * @Override
+     * @Override
      * protected void setAdditional(ClientOptions.Builder builder) {
-     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
      *     builder.addHeader("X-Client-Version", "1.0.0");
      * }
      * }
@@ -231,7 +258,7 @@ protected void setAdditional(ClientOptions.Builder builder) {} * * Example: *
{@code
-     * @Override
+     * @Override
      * protected void validateConfiguration() {
      *     super.validateConfiguration(); // Run parent validations
      *     if (tenantId == null || tenantId.isEmpty()) {
diff --git a/src/main/java/com/pipedream/api/AsyncPipedreamClient.java b/src/main/java/com/pipedream/api/AsyncPipedreamClient.java
deleted file mode 100644
index c0464da..0000000
--- a/src/main/java/com/pipedream/api/AsyncPipedreamClient.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.pipedream.api;
-
-import com.pipedream.api.core.ClientOptions;
-import com.pipedream.api.core.Environment;
-import com.pipedream.api.core.Suppliers;
-import com.pipedream.api.resources.workflows.WorkflowsClient;
-import java.util.Optional;
-import java.util.function.Supplier;
-
-public class AsyncPipedreamClient extends AsyncBaseClient {
-    private final Supplier workflowsClient;
-
-    public AsyncPipedreamClient(final ClientOptions clientOptions) {
-        super(clientOptions);
-        this.workflowsClient = Suppliers.memoize(() -> new WorkflowsClient(clientOptions));
-    }
-
-    public static AsyncPipedreamClientBuilder builder() {
-        return new AsyncPipedreamClientBuilder()
-                .clientId(System.getenv("PIPEDREAM_CLIENT_ID"))
-                .clientSecret(System.getenv("PIPEDREAM_CLIENT_SECRET"))
-                .environment(Environment.PROD)
-                .projectEnvironment(System.getenv("PIPEDREAM_PROJECT_ENVIRONMENT"))
-                .projectId(System.getenv("PIPEDREAM_PROJECT_ID"));
-    }
-
-    /**
-     * Returns an access token that can be used to authenticate API requests
-     *
-     * @return the access token string (if available)
-     */
-    public Optional rawAccessToken() {
-        final String authorizationHeader = this.clientOptions.headers(null).get("Authorization");
-
-        // The header might not be defined, so we wrap it as an Optional to
-        // further process it. The processing consists of removing the `Bearer`
-        // or `Basic` prefix from the header value.
-        return Optional.ofNullable(authorizationHeader).map(h -> h.replaceFirst("^.*?\\s+", ""));
-    }
-
-    public WorkflowsClient workflows() {
-        return this.workflowsClient.get();
-    }
-}
diff --git a/src/main/java/com/pipedream/api/AsyncPipedreamClientBuilder.java b/src/main/java/com/pipedream/api/AsyncPipedreamClientBuilder.java
deleted file mode 100644
index 8dc55ad..0000000
--- a/src/main/java/com/pipedream/api/AsyncPipedreamClientBuilder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.pipedream.api;
-
-import com.pipedream.api.core.ClientOptions;
-import com.pipedream.api.core.Environment;
-import org.apache.commons.text.StringSubstitutor;
-import org.apache.commons.text.lookup.StringLookupFactory;
-
-/**
- * Builder for creating AsyncPipedreamClient instances.
- */
-public final class AsyncPipedreamClientBuilder extends AsyncBaseClientBuilder {
-    private String projectId;
-
-    public AsyncPipedreamClient build() {
-        return new AsyncPipedreamClient(buildClientOptions());
-    }
-
-    public AsyncPipedreamClientBuilder environment(final Environment environment) {
-        final String patchedUrl = patchUrl(environment.getUrl());
-        final Environment withPatchedUrl = Environment.custom(patchedUrl);
-        super.environment(withPatchedUrl);
-        return this;
-    }
-
-    public AsyncPipedreamClientBuilder projectId(final String projectId) {
-        this.projectId = projectId;
-        return this;
-    }
-
-    @Override
-    public void setVariables(ClientOptions.Builder builder) {
-        builder.projectId(this.projectId);
-    }
-
-    private static String patchUrl(final String templateUrl) {
-        StringSubstitutor sub = new StringSubstitutor(StringLookupFactory.INSTANCE.environmentVariableStringLookup());
-
-        return sub.replace(templateUrl);
-    }
-}
diff --git a/src/main/java/com/pipedream/api/BaseClient.java b/src/main/java/com/pipedream/api/BaseClient.java
index 69e5677..387fe22 100644
--- a/src/main/java/com/pipedream/api/BaseClient.java
+++ b/src/main/java/com/pipedream/api/BaseClient.java
@@ -11,6 +11,7 @@
 import com.pipedream.api.resources.apps.AppsClient;
 import com.pipedream.api.resources.components.ComponentsClient;
 import com.pipedream.api.resources.deployedtriggers.DeployedTriggersClient;
+import com.pipedream.api.resources.filestash.FileStashClient;
 import com.pipedream.api.resources.oauthtokens.OauthTokensClient;
 import com.pipedream.api.resources.projects.ProjectsClient;
 import com.pipedream.api.resources.proxy.ProxyClient;
@@ -40,6 +41,8 @@ public class BaseClient {
 
     protected final Supplier projectsClient;
 
+    protected final Supplier fileStashClient;
+
     protected final Supplier proxyClient;
 
     protected final Supplier tokensClient;
@@ -57,6 +60,7 @@ public BaseClient(ClientOptions clientOptions) {
         this.triggersClient = Suppliers.memoize(() -> new TriggersClient(clientOptions));
         this.deployedTriggersClient = Suppliers.memoize(() -> new DeployedTriggersClient(clientOptions));
         this.projectsClient = Suppliers.memoize(() -> new ProjectsClient(clientOptions));
+        this.fileStashClient = Suppliers.memoize(() -> new FileStashClient(clientOptions));
         this.proxyClient = Suppliers.memoize(() -> new ProxyClient(clientOptions));
         this.tokensClient = Suppliers.memoize(() -> new TokensClient(clientOptions));
         this.oauthTokensClient = Suppliers.memoize(() -> new OauthTokensClient(clientOptions));
@@ -98,6 +102,10 @@ public ProjectsClient projects() {
         return this.projectsClient.get();
     }
 
+    public FileStashClient fileStash() {
+        return this.fileStashClient.get();
+    }
+
     public ProxyClient proxy() {
         return this.proxyClient.get();
     }
diff --git a/src/main/java/com/pipedream/api/BaseClientBuilder.java b/src/main/java/com/pipedream/api/BaseClientBuilder.java
index 79c1350..ba2a069 100644
--- a/src/main/java/com/pipedream/api/BaseClientBuilder.java
+++ b/src/main/java/com/pipedream/api/BaseClientBuilder.java
@@ -7,14 +7,18 @@
 import com.pipedream.api.core.Environment;
 import com.pipedream.api.core.OAuthTokenSupplier;
 import com.pipedream.api.resources.oauthtokens.OauthTokensClient;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Optional;
 import okhttp3.OkHttpClient;
 
-public class BaseClientBuilder> {
+public class BaseClientBuilder {
     private Optional timeout = Optional.empty();
 
     private Optional maxRetries = Optional.empty();
 
+    private final Map customHeaders = new HashMap<>();
+
     private String clientId = System.getenv("PIPEDREAM_CLIENT_ID");
 
     private String clientSecret = System.getenv("PIPEDREAM_CLIENT_SECRET");
@@ -25,72 +29,84 @@ public class BaseClientBuilder> {
 
     private OkHttpClient httpClient;
 
+    private String projectId;
+
     /**
      * Sets clientId.
      * Defaults to the PIPEDREAM_CLIENT_ID environment variable.
      */
-    @SuppressWarnings("unchecked")
-    public T clientId(String clientId) {
+    public BaseClientBuilder clientId(String clientId) {
         this.clientId = clientId;
-        return (T) this;
+        return this;
     }
 
     /**
      * Sets clientSecret.
      * Defaults to the PIPEDREAM_CLIENT_SECRET environment variable.
      */
-    @SuppressWarnings("unchecked")
-    public T clientSecret(String clientSecret) {
+    public BaseClientBuilder clientSecret(String clientSecret) {
         this.clientSecret = clientSecret;
-        return (T) this;
+        return this;
     }
 
     /**
      * Sets projectEnvironment
      */
-    @SuppressWarnings("unchecked")
-    public T projectEnvironment(String projectEnvironment) {
+    public BaseClientBuilder projectEnvironment(String projectEnvironment) {
         this.projectEnvironment = projectEnvironment;
-        return (T) this;
+        return this;
     }
 
-    @SuppressWarnings("unchecked")
-    public T environment(Environment environment) {
+    public BaseClientBuilder environment(Environment environment) {
         this.environment = environment;
-        return (T) this;
+        return this;
     }
 
-    @SuppressWarnings("unchecked")
-    public T url(String url) {
+    public BaseClientBuilder url(String url) {
         this.environment = Environment.custom(url);
-        return (T) this;
+        return this;
     }
 
     /**
      * Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
      */
-    @SuppressWarnings("unchecked")
-    public T timeout(int timeout) {
+    public BaseClientBuilder timeout(int timeout) {
         this.timeout = Optional.of(timeout);
-        return (T) this;
+        return this;
     }
 
     /**
      * Sets the maximum number of retries for the client. Defaults to 2 retries.
      */
-    @SuppressWarnings("unchecked")
-    public T maxRetries(int maxRetries) {
+    public BaseClientBuilder maxRetries(int maxRetries) {
         this.maxRetries = Optional.of(maxRetries);
-        return (T) this;
+        return this;
     }
 
     /**
      * Sets the underlying OkHttp client
      */
-    @SuppressWarnings("unchecked")
-    public T httpClient(OkHttpClient httpClient) {
+    public BaseClientBuilder httpClient(OkHttpClient httpClient) {
         this.httpClient = httpClient;
-        return (T) this;
+        return this;
+    }
+
+    /**
+     * Add a custom header to be sent with all requests.
+     * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
+     *
+     * @param name The header name
+     * @param value The header value
+     * @return This builder for method chaining
+     */
+    public BaseClientBuilder addHeader(String name, String value) {
+        this.customHeaders.put(name, value);
+        return this;
+    }
+
+    public BaseClientBuilder projectId(String projectId) {
+        this.projectId = projectId;
+        return this;
     }
 
     protected ClientOptions buildClientOptions() {
@@ -102,6 +118,9 @@ protected ClientOptions buildClientOptions() {
         setHttpClient(builder);
         setTimeouts(builder);
         setRetries(builder);
+        for (Map.Entry header : this.customHeaders.entrySet()) {
+            builder.addHeader(header.getKey(), header.getValue());
+        }
         setAdditional(builder);
         return builder.build();
     }
@@ -124,7 +143,7 @@ protected void setEnvironment(ClientOptions.Builder builder) {
      *
      * Example:
      * 
{@code
-     * @Override
+     * @Override
      * protected void setAuthentication(ClientOptions.Builder builder) {
      *     super.setAuthentication(builder); // Keep existing auth
      *     builder.addHeader("X-API-Key", this.apiKey);
@@ -133,8 +152,12 @@ protected void setEnvironment(ClientOptions.Builder builder) {
      */
     protected void setAuthentication(ClientOptions.Builder builder) {
         if (this.clientId != null && this.clientSecret != null) {
-            OauthTokensClient authClient = new OauthTokensClient(
-                    ClientOptions.builder().environment(this.environment).build());
+            ClientOptions.Builder authClientOptionsBuilder =
+                    ClientOptions.builder().environment(this.environment);
+            if (this.projectId != null) {
+                authClientOptionsBuilder.projectId(this.projectId);
+            }
+            OauthTokensClient authClient = new OauthTokensClient(authClientOptionsBuilder.build());
             OAuthTokenSupplier oAuthTokenSupplier =
                     new OAuthTokenSupplier(this.clientId, this.clientSecret, authClient);
             builder.addHeader("Authorization", oAuthTokenSupplier);
@@ -149,7 +172,7 @@ protected void setAuthentication(ClientOptions.Builder builder) {
      *
      * Example:
      * 
{@code
-     * @Override
+     * @Override
      * protected void setCustomHeaders(ClientOptions.Builder builder) {
      *     super.setCustomHeaders(builder); // Keep existing headers
      *     builder.addHeader("X-Trace-ID", generateTraceId());
@@ -168,7 +191,11 @@ protected void setCustomHeaders(ClientOptions.Builder builder) {
      *
      * @param builder The ClientOptions.Builder to configure
      */
-    protected void setVariables(ClientOptions.Builder builder) {}
+    protected void setVariables(ClientOptions.Builder builder) {
+        if (this.projectId != null) {
+            builder.projectId(this.projectId);
+        }
+    }
 
     /**
      * Sets the request timeout configuration.
@@ -215,9 +242,9 @@ protected void setHttpClient(ClientOptions.Builder builder) {
      *
      * Example:
      * 
{@code
-     * @Override
+     * @Override
      * protected void setAdditional(ClientOptions.Builder builder) {
-     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
      *     builder.addHeader("X-Client-Version", "1.0.0");
      * }
      * }
@@ -231,7 +258,7 @@ protected void setAdditional(ClientOptions.Builder builder) {} * * Example: *
{@code
-     * @Override
+     * @Override
      * protected void validateConfiguration() {
      *     super.validateConfiguration(); // Run parent validations
      *     if (tenantId == null || tenantId.isEmpty()) {
diff --git a/src/main/java/com/pipedream/api/PipedreamClient.java b/src/main/java/com/pipedream/api/PipedreamClient.java
deleted file mode 100644
index 8e916c9..0000000
--- a/src/main/java/com/pipedream/api/PipedreamClient.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.pipedream.api;
-
-import com.pipedream.api.core.ClientOptions;
-import com.pipedream.api.core.Environment;
-import com.pipedream.api.core.Suppliers;
-import com.pipedream.api.resources.workflows.WorkflowsClient;
-import java.util.Optional;
-import java.util.function.Supplier;
-
-public class PipedreamClient extends BaseClient {
-    private final Supplier workflowsClient;
-
-    public PipedreamClient(final ClientOptions clientOptions) {
-        super(clientOptions);
-        this.workflowsClient = Suppliers.memoize(() -> new WorkflowsClient(clientOptions));
-    }
-
-    public static PipedreamClientBuilder builder() {
-        return new PipedreamClientBuilder()
-                .clientId(System.getenv("PIPEDREAM_CLIENT_ID"))
-                .clientSecret(System.getenv("PIPEDREAM_CLIENT_SECRET"))
-                .environment(Environment.PROD)
-                .projectEnvironment(System.getenv("PIPEDREAM_PROJECT_ENVIRONMENT"))
-                .projectId(System.getenv("PIPEDREAM_PROJECT_ID"));
-    }
-
-    /**
-     * Returns an access token that can be used to authenticate API requests
-     *
-     * @return the access token string (if available)
-     */
-    public Optional rawAccessToken() {
-        final String authorizationHeader = this.clientOptions.headers(null).get("Authorization");
-
-        // The header might not be defined, so we wrap it as an Optional to
-        // further process it. The processing consists of removing the `Bearer`
-        // or `Basic` prefix from the header value.
-        return Optional.ofNullable(authorizationHeader).map(h -> h.replaceFirst("^.*?\\s+", ""));
-    }
-
-    public WorkflowsClient workflows() {
-        return this.workflowsClient.get();
-    }
-}
diff --git a/src/main/java/com/pipedream/api/PipedreamClientBuilder.java b/src/main/java/com/pipedream/api/PipedreamClientBuilder.java
deleted file mode 100644
index 2722b8b..0000000
--- a/src/main/java/com/pipedream/api/PipedreamClientBuilder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.pipedream.api;
-
-import com.pipedream.api.core.ClientOptions;
-import com.pipedream.api.core.Environment;
-import org.apache.commons.text.StringSubstitutor;
-import org.apache.commons.text.lookup.StringLookupFactory;
-
-/**
- * Builder for creating PipedreamClient instances.
- */
-public final class PipedreamClientBuilder extends BaseClientBuilder {
-    private String projectId;
-
-    public PipedreamClient build() {
-        return new PipedreamClient(buildClientOptions());
-    }
-
-    public PipedreamClientBuilder environment(final Environment environment) {
-        final String patchedUrl = patchUrl(environment.getUrl());
-        final Environment withPatchedUrl = Environment.custom(patchedUrl);
-        super.environment(withPatchedUrl);
-        return this;
-    }
-
-    public PipedreamClientBuilder projectId(final String projectId) {
-        this.projectId = projectId;
-        return this;
-    }
-
-    @Override
-    public void setVariables(ClientOptions.Builder builder) {
-        builder.projectId(this.projectId);
-    }
-
-    private static String patchUrl(final String templateUrl) {
-        StringSubstitutor sub = new StringSubstitutor(StringLookupFactory.INSTANCE.environmentVariableStringLookup());
-
-        return sub.replace(templateUrl);
-    }
-}
diff --git a/src/main/java/com/pipedream/api/core/ClientOptions.java b/src/main/java/com/pipedream/api/core/ClientOptions.java
index 1dd75f9..8e17e45 100644
--- a/src/main/java/com/pipedream/api/core/ClientOptions.java
+++ b/src/main/java/com/pipedream/api/core/ClientOptions.java
@@ -35,10 +35,10 @@ private ClientOptions(
         this.headers.putAll(headers);
         this.headers.putAll(new HashMap() {
             {
-                put("User-Agent", "com.pipedream:pipedream/1.0.5");
+                put("User-Agent", "com.pipedream:pipedream/1.0.6");
                 put("X-Fern-Language", "JAVA");
                 put("X-Fern-SDK-Name", "com.pipedream.fern:api-sdk");
-                put("X-Fern-SDK-Version", "1.0.5");
+                put("X-Fern-SDK-Version", "1.0.6");
             }
         });
         this.headerSuppliers = headerSuppliers;
diff --git a/src/main/java/com/pipedream/api/core/Stream.java b/src/main/java/com/pipedream/api/core/Stream.java
index 3781dcc..c6cba9f 100644
--- a/src/main/java/com/pipedream/api/core/Stream.java
+++ b/src/main/java/com/pipedream/api/core/Stream.java
@@ -174,8 +174,8 @@ private final class SSEIterator implements Iterator {
         private T nextItem;
         private boolean hasNextItem = false;
         private boolean endOfStream = false;
-        private StringBuilder buffer = new StringBuilder();
-        private boolean prefixSeen = false;
+        private StringBuilder eventDataBuffer = new StringBuilder();
+        private String currentEventType = null;
 
         private SSEIterator() {
             if (sseReader != null && !isStreamClosed()) {
@@ -223,39 +223,69 @@ private boolean readNextMessage() {
 
             try {
                 while (sseScanner.hasNextLine()) {
-                    String chunk = sseScanner.nextLine();
-                    buffer.append(chunk).append(NEWLINE);
-
-                    int terminatorIndex;
-                    while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) {
-                        String line = buffer.substring(0, terminatorIndex + messageTerminator.length());
-                        buffer.delete(0, terminatorIndex + messageTerminator.length());
-
-                        line = line.trim();
-                        if (line.isEmpty()) {
-                            continue;
+                    String line = sseScanner.nextLine();
+
+                    if (line.trim().isEmpty()) {
+                        if (eventDataBuffer.length() > 0) {
+                            try {
+                                nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
+                                hasNextItem = true;
+                                eventDataBuffer.setLength(0);
+                                currentEventType = null;
+                                return true;
+                            } catch (Exception parseEx) {
+                                System.err.println("Failed to parse SSE event: " + parseEx.getMessage());
+                                eventDataBuffer.setLength(0);
+                                currentEventType = null;
+                                continue;
+                            }
                         }
+                        continue;
+                    }
 
-                        if (!prefixSeen && line.startsWith(DATA_PREFIX)) {
-                            prefixSeen = true;
-                            line = line.substring(DATA_PREFIX.length()).trim();
-                        } else if (!prefixSeen) {
-                            continue;
+                    if (line.startsWith(DATA_PREFIX)) {
+                        String dataContent = line.substring(DATA_PREFIX.length());
+                        if (dataContent.startsWith(" ")) {
+                            dataContent = dataContent.substring(1);
                         }
 
-                        if (streamTerminator != null && line.contains(streamTerminator)) {
+                        if (eventDataBuffer.length() == 0
+                                && streamTerminator != null
+                                && dataContent.trim().equals(streamTerminator)) {
                             endOfStream = true;
                             return false;
                         }
 
-                        try {
-                            nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType);
-                            hasNextItem = true;
-                            prefixSeen = false;
-                            return true;
-                        } catch (Exception parseEx) {
-                            continue;
+                        if (eventDataBuffer.length() > 0) {
+                            eventDataBuffer.append('\n');
+                        }
+                        eventDataBuffer.append(dataContent);
+                    } else if (line.startsWith("event:")) {
+                        String eventValue = line.length() > 6 ? line.substring(6) : "";
+                        if (eventValue.startsWith(" ")) {
+                            eventValue = eventValue.substring(1);
                         }
+                        currentEventType = eventValue;
+                    } else if (line.startsWith("id:")) {
+                        // Event ID field (ignored)
+                    } else if (line.startsWith("retry:")) {
+                        // Retry field (ignored)
+                    } else if (line.startsWith(":")) {
+                        // Comment line (ignored)
+                    }
+                }
+
+                if (eventDataBuffer.length() > 0) {
+                    try {
+                        nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
+                        hasNextItem = true;
+                        eventDataBuffer.setLength(0);
+                        currentEventType = null;
+                        return true;
+                    } catch (Exception parseEx) {
+                        System.err.println("Failed to parse final SSE event: " + parseEx.getMessage());
+                        eventDataBuffer.setLength(0);
+                        currentEventType = null;
                     }
                 }
 
diff --git a/src/main/java/com/pipedream/api/core/pagination/BasePage.java b/src/main/java/com/pipedream/api/core/pagination/BasePage.java
index ca83fe4..caaf807 100644
--- a/src/main/java/com/pipedream/api/core/pagination/BasePage.java
+++ b/src/main/java/com/pipedream/api/core/pagination/BasePage.java
@@ -4,14 +4,17 @@
 package com.pipedream.api.core.pagination;
 
 import java.util.List;
+import java.util.Optional;
 
 public abstract class BasePage {
     private final boolean hasNext;
     private final List items;
+    private final Object response;
 
-    public BasePage(boolean hasNext, List items) {
+    public BasePage(boolean hasNext, List items, Object response) {
         this.hasNext = hasNext;
         this.items = items;
+        this.response = response;
     }
 
     public boolean hasNext() {
@@ -21,4 +24,15 @@ public boolean hasNext() {
     public List getItems() {
         return items;
     }
+
+    /**
+     * Returns the full response object for accessing pagination metadata like cursor tokens.
+     *
+     * @return Optional containing the response, or empty if unavailable
+     */
+    public  Optional getResponse() {
+        @SuppressWarnings("unchecked")
+        R typedResponse = (R) response;
+        return Optional.ofNullable(typedResponse);
+    }
 }
diff --git a/src/main/java/com/pipedream/api/core/pagination/SyncPage.java b/src/main/java/com/pipedream/api/core/pagination/SyncPage.java
index 86fc5b7..ec28347 100644
--- a/src/main/java/com/pipedream/api/core/pagination/SyncPage.java
+++ b/src/main/java/com/pipedream/api/core/pagination/SyncPage.java
@@ -10,8 +10,8 @@
 public class SyncPage extends BasePage {
     protected final Supplier> nextSupplier;
 
-    public SyncPage(boolean hasNext, List items, Supplier> nextSupplier) {
-        super(hasNext, items);
+    public SyncPage(boolean hasNext, List items, Object response, Supplier> nextSupplier) {
+        super(hasNext, items, response);
         this.nextSupplier = nextSupplier;
     }
 
diff --git a/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java b/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java
index fd5fca3..09f7ca1 100644
--- a/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java
+++ b/src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java
@@ -14,12 +14,14 @@
 
 public class SyncPagingIterable extends SyncPage implements Iterable {
 
-    public SyncPagingIterable(boolean hasNext, List items, Supplier> getNext) {
-        super(hasNext, items, getNext);
+    public SyncPagingIterable(
+            boolean hasNext, List items, Object response, Supplier> getNext) {
+        super(hasNext, items, response, getNext);
     }
 
-    public SyncPagingIterable(boolean hasNext, Optional> items, Supplier> getNext) {
-        super(hasNext, items.orElse(new ArrayList<>()), getNext);
+    public SyncPagingIterable(
+            boolean hasNext, Optional> items, Object response, Supplier> getNext) {
+        super(hasNext, items.orElse(new ArrayList<>()), response, getNext);
     }
 
     public Stream streamItems() {
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 3aff3e1..ea6cbb9 100644
--- a/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
+++ b/src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java
@@ -68,10 +68,6 @@ public CompletableFuture>> li
                 .addPathSegments("v1/connect")
                 .addPathSegment(clientOptions.projectId())
                 .addPathSegments("accounts");
-        if (request.getAppId().isPresent()) {
-            QueryStringMapper.addQueryParameter(
-                    httpUrl, "app_id", request.getAppId().get(), false);
-        }
         if (request.getExternalUserId().isPresent()) {
             QueryStringMapper.addQueryParameter(
                     httpUrl, "external_user_id", request.getExternalUserId().get(), false);
@@ -92,6 +88,9 @@ public CompletableFuture>> li
             QueryStringMapper.addQueryParameter(
                     httpUrl, "limit", request.getLimit().get(), false);
         }
+        if (request.getApp().isPresent()) {
+            QueryStringMapper.addQueryParameter(httpUrl, "app", request.getApp().get(), false);
+        }
         if (request.getIncludeCredentials().isPresent()) {
             QueryStringMapper.addQueryParameter(
                     httpUrl,
@@ -125,15 +124,16 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
                                 .build();
                         List result = parsedResponse.getData();
                         future.complete(new BaseClientHttpResponse<>(
-                                new SyncPagingIterable(startingAfter.isPresent(), result, () -> {
-                                    try {
-                                        return list(nextRequest, requestOptions)
-                                                .get()
-                                                .body();
-                                    } catch (InterruptedException | ExecutionException e) {
-                                        throw new RuntimeException(e);
-                                    }
-                                }),
+                                new SyncPagingIterable(
+                                        startingAfter.isPresent(), result, parsedResponse, () -> {
+                                            try {
+                                                return list(nextRequest, requestOptions)
+                                                        .get()
+                                                        .body();
+                                            } catch (InterruptedException | ExecutionException e) {
+                                                throw new RuntimeException(e);
+                                            }
+                                        }),
                                 response));
                         return;
                     }
@@ -183,10 +183,6 @@ public CompletableFuture> create(
                 .addPathSegments("v1/connect")
                 .addPathSegment(clientOptions.projectId())
                 .addPathSegments("accounts");
-        if (request.getAppId().isPresent()) {
-            QueryStringMapper.addQueryParameter(
-                    httpUrl, "app_id", request.getAppId().get(), false);
-        }
         if (request.getExternalUserId().isPresent()) {
             QueryStringMapper.addQueryParameter(
                     httpUrl, "external_user_id", request.getExternalUserId().get(), false);
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 9692016..61469b7 100644
--- a/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
+++ b/src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java
@@ -63,10 +63,6 @@ public BaseClientHttpResponse> list(
                 .addPathSegments("v1/connect")
                 .addPathSegment(clientOptions.projectId())
                 .addPathSegments("accounts");
-        if (request.getAppId().isPresent()) {
-            QueryStringMapper.addQueryParameter(
-                    httpUrl, "app_id", request.getAppId().get(), false);
-        }
         if (request.getExternalUserId().isPresent()) {
             QueryStringMapper.addQueryParameter(
                     httpUrl, "external_user_id", request.getExternalUserId().get(), false);
@@ -87,6 +83,9 @@ public BaseClientHttpResponse> list(
             QueryStringMapper.addQueryParameter(
                     httpUrl, "limit", request.getLimit().get(), false);
         }
+        if (request.getApp().isPresent()) {
+            QueryStringMapper.addQueryParameter(httpUrl, "app", request.getApp().get(), false);
+        }
         if (request.getIncludeCredentials().isPresent()) {
             QueryStringMapper.addQueryParameter(
                     httpUrl,
@@ -116,9 +115,9 @@ public BaseClientHttpResponse> list(
                         .build();
                 List result = parsedResponse.getData();
                 return new BaseClientHttpResponse<>(
-                        new SyncPagingIterable(
-                                startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions)
-                                        .body()),
+                        new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list(
+                                        nextRequest, requestOptions)
+                                .body()),
                         response);
             }
             String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -156,10 +155,6 @@ public BaseClientHttpResponse create(CreateAccountOpts request, Request
                 .addPathSegments("v1/connect")
                 .addPathSegment(clientOptions.projectId())
                 .addPathSegments("accounts");
-        if (request.getAppId().isPresent()) {
-            QueryStringMapper.addQueryParameter(
-                    httpUrl, "app_id", request.getAppId().get(), false);
-        }
         if (request.getExternalUserId().isPresent()) {
             QueryStringMapper.addQueryParameter(
                     httpUrl, "external_user_id", request.getExternalUserId().get(), false);
diff --git a/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java b/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java
index 2d67f6d..bfba211 100644
--- a/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java
+++ b/src/main/java/com/pipedream/api/resources/accounts/requests/AccountsListRequest.java
@@ -20,8 +20,6 @@
 @JsonInclude(JsonInclude.Include.NON_ABSENT)
 @JsonDeserialize(builder = AccountsListRequest.Builder.class)
 public final class AccountsListRequest {
-    private final Optional appId;
-
     private final Optional externalUserId;
 
     private final Optional oauthAppId;
@@ -32,37 +30,31 @@ public final class AccountsListRequest {
 
     private final Optional limit;
 
+    private final Optional app;
+
     private final Optional includeCredentials;
 
     private final Map additionalProperties;
 
     private AccountsListRequest(
-            Optional appId,
             Optional externalUserId,
             Optional oauthAppId,
             Optional after,
             Optional before,
             Optional limit,
+            Optional app,
             Optional includeCredentials,
             Map additionalProperties) {
-        this.appId = appId;
         this.externalUserId = externalUserId;
         this.oauthAppId = oauthAppId;
         this.after = after;
         this.before = before;
         this.limit = limit;
+        this.app = app;
         this.includeCredentials = includeCredentials;
         this.additionalProperties = additionalProperties;
     }
 
-    /**
-     * @return The app slug or ID to filter accounts by.
-     */
-    @JsonProperty("app_id")
-    public Optional getAppId() {
-        return appId;
-    }
-
     @JsonProperty("external_user_id")
     public Optional getExternalUserId() {
         return externalUserId;
@@ -100,6 +92,14 @@ public Optional getLimit() {
         return limit;
     }
 
+    /**
+     * @return The app slug or ID to filter accounts by.
+     */
+    @JsonProperty("app")
+    public Optional getApp() {
+        return app;
+    }
+
     /**
      * @return Whether to retrieve the account's credentials or not
      */
@@ -120,24 +120,24 @@ public Map getAdditionalProperties() {
     }
 
     private boolean equalTo(AccountsListRequest other) {
-        return appId.equals(other.appId)
-                && externalUserId.equals(other.externalUserId)
+        return externalUserId.equals(other.externalUserId)
                 && oauthAppId.equals(other.oauthAppId)
                 && after.equals(other.after)
                 && before.equals(other.before)
                 && limit.equals(other.limit)
+                && app.equals(other.app)
                 && includeCredentials.equals(other.includeCredentials);
     }
 
     @java.lang.Override
     public int hashCode() {
         return Objects.hash(
-                this.appId,
                 this.externalUserId,
                 this.oauthAppId,
                 this.after,
                 this.before,
                 this.limit,
+                this.app,
                 this.includeCredentials);
     }
 
@@ -152,8 +152,6 @@ public static Builder builder() {
 
     @JsonIgnoreProperties(ignoreUnknown = true)
     public static final class Builder {
-        private Optional appId = Optional.empty();
-
         private Optional externalUserId = Optional.empty();
 
         private Optional oauthAppId = Optional.empty();
@@ -164,6 +162,8 @@ public static final class Builder {
 
         private Optional limit = Optional.empty();
 
+        private Optional app = Optional.empty();
+
         private Optional includeCredentials = Optional.empty();
 
         @JsonAnySetter
@@ -172,30 +172,16 @@ public static final class Builder {
         private Builder() {}
 
         public Builder from(AccountsListRequest other) {
-            appId(other.getAppId());
             externalUserId(other.getExternalUserId());
             oauthAppId(other.getOauthAppId());
             after(other.getAfter());
             before(other.getBefore());
             limit(other.getLimit());
+            app(other.getApp());
             includeCredentials(other.getIncludeCredentials());
             return this;
         }
 
-        /**
-         * 

The app slug or ID to filter accounts by.

- */ - @JsonSetter(value = "app_id", nulls = Nulls.SKIP) - public Builder appId(Optional appId) { - this.appId = appId; - return this; - } - - public Builder appId(String appId) { - this.appId = Optional.ofNullable(appId); - return this; - } - @JsonSetter(value = "external_user_id", nulls = Nulls.SKIP) public Builder externalUserId(Optional externalUserId) { this.externalUserId = externalUserId; @@ -263,6 +249,20 @@ public Builder limit(Integer limit) { return this; } + /** + *

The app slug or ID to filter accounts by.

+ */ + @JsonSetter(value = "app", nulls = Nulls.SKIP) + public Builder app(Optional app) { + this.app = app; + return this; + } + + public Builder app(String app) { + this.app = Optional.ofNullable(app); + return this; + } + /** *

Whether to retrieve the account's credentials or not

*/ @@ -279,7 +279,7 @@ public Builder includeCredentials(Boolean includeCredentials) { public AccountsListRequest build() { return new AccountsListRequest( - appId, externalUserId, oauthAppId, after, before, limit, includeCredentials, additionalProperties); + externalUserId, oauthAppId, after, before, limit, app, includeCredentials, additionalProperties); } } } 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 79cef5e..d168d25 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 @@ -21,8 +21,6 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateAccountOpts.Builder.class) public final class CreateAccountOpts { - private final Optional appId; - private final Optional externalUserId; private final Optional oauthAppId; @@ -38,7 +36,6 @@ public final class CreateAccountOpts { private final Map additionalProperties; private CreateAccountOpts( - Optional appId, Optional externalUserId, Optional oauthAppId, String appSlug, @@ -46,7 +43,6 @@ private CreateAccountOpts( String connectToken, Optional name, Map additionalProperties) { - this.appId = appId; this.externalUserId = externalUserId; this.oauthAppId = oauthAppId; this.appSlug = appSlug; @@ -56,14 +52,6 @@ private CreateAccountOpts( this.additionalProperties = additionalProperties; } - /** - * @return The app slug or ID to filter accounts by. - */ - @JsonProperty("app_id") - public Optional getAppId() { - return appId; - } - @JsonProperty("external_user_id") public Optional getExternalUserId() { return externalUserId; @@ -121,8 +109,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateAccountOpts other) { - return appId.equals(other.appId) - && externalUserId.equals(other.externalUserId) + return externalUserId.equals(other.externalUserId) && oauthAppId.equals(other.oauthAppId) && appSlug.equals(other.appSlug) && cfmapJson.equals(other.cfmapJson) @@ -133,13 +120,7 @@ private boolean equalTo(CreateAccountOpts other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.appId, - this.externalUserId, - this.oauthAppId, - this.appSlug, - this.cfmapJson, - this.connectToken, - this.name); + this.externalUserId, this.oauthAppId, this.appSlug, this.cfmapJson, this.connectToken, this.name); } @java.lang.Override @@ -177,13 +158,6 @@ public interface ConnectTokenStage { public interface _FinalStage { CreateAccountOpts build(); - /** - *

The app slug or ID to filter accounts by.

- */ - _FinalStage appId(Optional appId); - - _FinalStage appId(String appId); - _FinalStage externalUserId(Optional externalUserId); _FinalStage externalUserId(String externalUserId); @@ -217,8 +191,6 @@ public static final class Builder implements AppSlugStage, CfmapJsonStage, Conne private Optional externalUserId = Optional.empty(); - private Optional appId = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -226,7 +198,6 @@ private Builder() {} @java.lang.Override public Builder from(CreateAccountOpts other) { - appId(other.getAppId()); externalUserId(other.getExternalUserId()); oauthAppId(other.getOauthAppId()); appSlug(other.getAppSlug()); @@ -325,30 +296,10 @@ public _FinalStage externalUserId(Optional externalUserId) { return this; } - /** - *

The app slug or ID to filter accounts by.

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

The app slug or ID to filter accounts by.

- */ - @java.lang.Override - @JsonSetter(value = "app_id", nulls = Nulls.SKIP) - public _FinalStage appId(Optional appId) { - this.appId = appId; - return this; - } - @java.lang.Override public CreateAccountOpts build() { return new CreateAccountOpts( - appId, externalUserId, oauthAppId, appSlug, cfmapJson, connectToken, name, additionalProperties); + externalUserId, oauthAppId, appSlug, cfmapJson, connectToken, name, additionalProperties); } } } 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 cd9c018..caee715 100644 --- a/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java +++ b/src/main/java/com/pipedream/api/resources/actions/AsyncRawActionsClient.java @@ -115,15 +115,16 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .build(); List result = parsedResponse.getData(); future.complete(new BaseClientHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return list(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } 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 8fb543b..a983c10 100644 --- a/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java +++ b/src/main/java/com/pipedream/api/resources/actions/RawActionsClient.java @@ -106,9 +106,9 @@ public BaseClientHttpResponse> list( .build(); List result = parsedResponse.getData(); return new BaseClientHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; 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 12b0e07..bfc2fde 100644 --- a/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java +++ b/src/main/java/com/pipedream/api/resources/apps/AsyncRawAppsClient.java @@ -112,7 +112,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .build(); List result = parsedResponse.getData(); future.complete(new BaseClientHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> { try { return list(nextRequest, requestOptions) .get() 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 e435a99..1a8e637 100644 --- a/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java +++ b/src/main/java/com/pipedream/api/resources/apps/RawAppsClient.java @@ -103,9 +103,9 @@ public BaseClientHttpResponse> list( .build(); List result = parsedResponse.getData(); return new BaseClientHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortDirection.java b/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortDirection.java index 18cc793..0e84e8f 100644 --- a/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortDirection.java +++ b/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortDirection.java @@ -3,22 +3,82 @@ */ package com.pipedream.api.resources.apps.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum AppsListRequestSortDirection { - ASC("asc"), +public final class AppsListRequestSortDirection { + public static final AppsListRequestSortDirection ASC = new AppsListRequestSortDirection(Value.ASC, "asc"); - DESC("desc"); + public static final AppsListRequestSortDirection DESC = new AppsListRequestSortDirection(Value.DESC, "desc"); - private final String value; + private final Value value; - AppsListRequestSortDirection(String value) { + private final String string; + + AppsListRequestSortDirection(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof AppsListRequestSortDirection + && this.string.equals(((AppsListRequestSortDirection) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static AppsListRequestSortDirection valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new AppsListRequestSortDirection(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortKey.java b/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortKey.java index 7260231..16800bb 100644 --- a/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortKey.java +++ b/src/main/java/com/pipedream/api/resources/apps/types/AppsListRequestSortKey.java @@ -3,24 +3,93 @@ */ package com.pipedream.api.resources.apps.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum AppsListRequestSortKey { - NAME("name"), +public final class AppsListRequestSortKey { + public static final AppsListRequestSortKey NAME_SLUG = new AppsListRequestSortKey(Value.NAME_SLUG, "name_slug"); - NAME_SLUG("name_slug"), + public static final AppsListRequestSortKey FEATURED_WEIGHT = + new AppsListRequestSortKey(Value.FEATURED_WEIGHT, "featured_weight"); - FEATURED_WEIGHT("featured_weight"); + public static final AppsListRequestSortKey NAME = new AppsListRequestSortKey(Value.NAME, "name"); - private final String value; + private final Value value; - AppsListRequestSortKey(String value) { + private final String string; + + AppsListRequestSortKey(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof AppsListRequestSortKey + && this.string.equals(((AppsListRequestSortKey) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NAME_SLUG: + return visitor.visitNameSlug(); + case FEATURED_WEIGHT: + return visitor.visitFeaturedWeight(); + case NAME: + return visitor.visitName(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static AppsListRequestSortKey valueOf(String value) { + switch (value) { + case "name_slug": + return NAME_SLUG; + case "featured_weight": + return FEATURED_WEIGHT; + case "name": + return NAME; + default: + return new AppsListRequestSortKey(Value.UNKNOWN, value); + } + } + + public enum Value { + NAME, + + NAME_SLUG, + + FEATURED_WEIGHT, + + UNKNOWN + } + + public interface Visitor { + T visitName(); + + T visitNameSlug(); + + T visitFeaturedWeight(); + + T visitUnknown(String unknownType); } } 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 f9290c2..ee4bdfa 100644 --- a/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java +++ b/src/main/java/com/pipedream/api/resources/components/AsyncRawComponentsClient.java @@ -118,15 +118,16 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .build(); List result = parsedResponse.getData(); future.complete(new BaseClientHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return list(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } 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 d9debeb..12eb6b7 100644 --- a/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java +++ b/src/main/java/com/pipedream/api/resources/components/RawComponentsClient.java @@ -108,9 +108,9 @@ public BaseClientHttpResponse> list( .build(); List result = parsedResponse.getData(); return new BaseClientHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncDeployedTriggersClient.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncDeployedTriggersClient.java index f069900..916aa4e 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncDeployedTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncDeployedTriggersClient.java @@ -17,6 +17,7 @@ import com.pipedream.api.resources.deployedtriggers.requests.UpdateTriggerWorkflowsOpts; import com.pipedream.api.types.DeployedComponent; import com.pipedream.api.types.EmittedEvent; +import com.pipedream.api.types.Emitter; import com.pipedream.api.types.GetTriggerWebhooksResponse; import com.pipedream.api.types.GetTriggerWorkflowsResponse; import java.util.List; @@ -42,14 +43,14 @@ public AsyncRawDeployedTriggersClient withRawResponse() { /** * Retrieve all deployed triggers for a specific external user */ - public CompletableFuture> list(DeployedTriggersListRequest request) { + public CompletableFuture> list(DeployedTriggersListRequest request) { return this.rawClient.list(request).thenApply(response -> response.body()); } /** * Retrieve all deployed triggers for a specific external user */ - public CompletableFuture> list( + public CompletableFuture> list( DeployedTriggersListRequest request, RequestOptions requestOptions) { return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); } 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 d350311..f10c1ef 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/AsyncRawDeployedTriggersClient.java @@ -25,6 +25,7 @@ import com.pipedream.api.resources.deployedtriggers.requests.UpdateTriggerWorkflowsOpts; import com.pipedream.api.types.DeployedComponent; import com.pipedream.api.types.EmittedEvent; +import com.pipedream.api.types.Emitter; import com.pipedream.api.types.GetTriggerEventsResponse; import com.pipedream.api.types.GetTriggerResponse; import com.pipedream.api.types.GetTriggerWebhooksResponse; @@ -58,7 +59,7 @@ public AsyncRawDeployedTriggersClient(ClientOptions clientOptions) { /** * Retrieve all deployed triggers for a specific external user */ - public CompletableFuture>> list( + public CompletableFuture>> list( DeployedTriggersListRequest request) { return list(request, null); } @@ -66,7 +67,7 @@ public CompletableFuture>> list( + public CompletableFuture>> list( DeployedTriggersListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -86,6 +87,10 @@ public CompletableFuture>> future = - new CompletableFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { @@ -111,17 +115,18 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .after(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData(); future.complete(new BaseClientHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return list(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/DeployedTriggersClient.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/DeployedTriggersClient.java index aa09ce2..fa03526 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/DeployedTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/DeployedTriggersClient.java @@ -17,6 +17,7 @@ import com.pipedream.api.resources.deployedtriggers.requests.UpdateTriggerWorkflowsOpts; import com.pipedream.api.types.DeployedComponent; import com.pipedream.api.types.EmittedEvent; +import com.pipedream.api.types.Emitter; import com.pipedream.api.types.GetTriggerWebhooksResponse; import com.pipedream.api.types.GetTriggerWorkflowsResponse; import java.util.List; @@ -41,15 +42,14 @@ public RawDeployedTriggersClient withRawResponse() { /** * Retrieve all deployed triggers for a specific external user */ - public SyncPagingIterable list(DeployedTriggersListRequest request) { + public SyncPagingIterable list(DeployedTriggersListRequest request) { return this.rawClient.list(request).body(); } /** * Retrieve all deployed triggers for a specific external user */ - public SyncPagingIterable list( - DeployedTriggersListRequest request, RequestOptions requestOptions) { + public SyncPagingIterable list(DeployedTriggersListRequest request, RequestOptions requestOptions) { return this.rawClient.list(request, requestOptions).body(); } 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 3134f2c..5301e3a 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/RawDeployedTriggersClient.java @@ -25,6 +25,7 @@ import com.pipedream.api.resources.deployedtriggers.requests.UpdateTriggerWorkflowsOpts; import com.pipedream.api.types.DeployedComponent; import com.pipedream.api.types.EmittedEvent; +import com.pipedream.api.types.Emitter; import com.pipedream.api.types.GetTriggerEventsResponse; import com.pipedream.api.types.GetTriggerResponse; import com.pipedream.api.types.GetTriggerWebhooksResponse; @@ -53,14 +54,14 @@ public RawDeployedTriggersClient(ClientOptions clientOptions) { /** * Retrieve all deployed triggers for a specific external user */ - public BaseClientHttpResponse> list(DeployedTriggersListRequest request) { + public BaseClientHttpResponse> list(DeployedTriggersListRequest request) { return list(request, null); } /** * Retrieve all deployed triggers for a specific external user */ - public BaseClientHttpResponse> list( + public BaseClientHttpResponse> list( DeployedTriggersListRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -80,6 +81,10 @@ public BaseClientHttpResponse> list( httpUrl, "limit", request.getLimit().get(), false); } QueryStringMapper.addQueryParameter(httpUrl, "external_user_id", request.getExternalUserId(), false); + if (request.getEmitterType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "emitter_type", request.getEmitterType().get(), false); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -100,11 +105,11 @@ public BaseClientHttpResponse> list( .from(request) .after(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData(); return new BaseClientHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/DeployedTriggersListRequest.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/DeployedTriggersListRequest.java index 556c4f0..28d94a0 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/DeployedTriggersListRequest.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/DeployedTriggersListRequest.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; +import com.pipedream.api.types.EmitterType; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -29,6 +30,8 @@ public final class DeployedTriggersListRequest { private final String externalUserId; + private final Optional emitterType; + private final Map additionalProperties; private DeployedTriggersListRequest( @@ -36,11 +39,13 @@ private DeployedTriggersListRequest( Optional before, Optional limit, String externalUserId, + Optional emitterType, Map additionalProperties) { this.after = after; this.before = before; this.limit = limit; this.externalUserId = externalUserId; + this.emitterType = emitterType; this.additionalProperties = additionalProperties; } @@ -76,6 +81,14 @@ public String getExternalUserId() { return externalUserId; } + /** + * @return Filter deployed triggers by emitter type (defaults to 'source' if not provided) + */ + @JsonProperty("emitter_type") + public Optional getEmitterType() { + return emitterType; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -91,12 +104,13 @@ private boolean equalTo(DeployedTriggersListRequest other) { return after.equals(other.after) && before.equals(other.before) && limit.equals(other.limit) - && externalUserId.equals(other.externalUserId); + && externalUserId.equals(other.externalUserId) + && emitterType.equals(other.emitterType); } @java.lang.Override public int hashCode() { - return Objects.hash(this.after, this.before, this.limit, this.externalUserId); + return Objects.hash(this.after, this.before, this.limit, this.externalUserId, this.emitterType); } @java.lang.Override @@ -140,12 +154,21 @@ public interface _FinalStage { _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + + /** + *

Filter deployed triggers by emitter type (defaults to 'source' if not provided)

+ */ + _FinalStage emitterType(Optional emitterType); + + _FinalStage emitterType(EmitterType emitterType); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ExternalUserIdStage, _FinalStage { private String externalUserId; + private Optional emitterType = Optional.empty(); + private Optional limit = Optional.empty(); private Optional before = Optional.empty(); @@ -163,6 +186,7 @@ public Builder from(DeployedTriggersListRequest other) { before(other.getBefore()); limit(other.getLimit()); externalUserId(other.getExternalUserId()); + emitterType(other.getEmitterType()); return this; } @@ -178,6 +202,26 @@ public _FinalStage externalUserId(@NotNull String externalUserId) { return this; } + /** + *

Filter deployed triggers by emitter type (defaults to 'source' if not provided)

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

Filter deployed triggers by emitter type (defaults to 'source' if not provided)

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

The maximum number of results to return

* @return Reference to {@code this} so that method calls can be chained together. @@ -240,7 +284,8 @@ public _FinalStage after(Optional after) { @java.lang.Override public DeployedTriggersListRequest build() { - return new DeployedTriggersListRequest(after, before, limit, externalUserId, additionalProperties); + return new DeployedTriggersListRequest( + after, before, limit, externalUserId, emitterType, additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWebhooksOpts.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWebhooksOpts.java index bf5b6a7..9c84d03 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWebhooksOpts.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWebhooksOpts.java @@ -161,7 +161,9 @@ public _FinalStage addWebhookUrls(String webhookUrls) { @JsonSetter(value = "webhook_urls", nulls = Nulls.SKIP) public _FinalStage webhookUrls(List webhookUrls) { this.webhookUrls.clear(); - this.webhookUrls.addAll(webhookUrls); + if (webhookUrls != null) { + this.webhookUrls.addAll(webhookUrls); + } return this; } diff --git a/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWorkflowsOpts.java b/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWorkflowsOpts.java index 6d042d9..eed070d 100644 --- a/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWorkflowsOpts.java +++ b/src/main/java/com/pipedream/api/resources/deployedtriggers/requests/UpdateTriggerWorkflowsOpts.java @@ -161,7 +161,9 @@ public _FinalStage addWorkflowIds(String workflowIds) { @JsonSetter(value = "workflow_ids", nulls = Nulls.SKIP) public _FinalStage workflowIds(List workflowIds) { this.workflowIds.clear(); - this.workflowIds.addAll(workflowIds); + if (workflowIds != null) { + this.workflowIds.addAll(workflowIds); + } return this; } diff --git a/src/main/java/com/pipedream/api/resources/filestash/AsyncFileStashClient.java b/src/main/java/com/pipedream/api/resources/filestash/AsyncFileStashClient.java index 72caf81..40ca561 100644 --- a/src/main/java/com/pipedream/api/resources/filestash/AsyncFileStashClient.java +++ b/src/main/java/com/pipedream/api/resources/filestash/AsyncFileStashClient.java @@ -6,6 +6,7 @@ import com.pipedream.api.core.ClientOptions; import com.pipedream.api.core.RequestOptions; import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest; +import java.io.InputStream; import java.util.concurrent.CompletableFuture; public class AsyncFileStashClient { @@ -28,14 +29,15 @@ public AsyncRawFileStashClient withRawResponse() { /** * Download a file from File Stash */ - public CompletableFuture downloadFile(FileStashDownloadFileRequest request) { + public CompletableFuture downloadFile(FileStashDownloadFileRequest request) { return this.rawClient.downloadFile(request).thenApply(response -> response.body()); } /** * Download a file from File Stash */ - public CompletableFuture downloadFile(FileStashDownloadFileRequest request, RequestOptions requestOptions) { + public CompletableFuture downloadFile( + FileStashDownloadFileRequest request, RequestOptions requestOptions) { return this.rawClient.downloadFile(request, requestOptions).thenApply(response -> response.body()); } } 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 89668b6..aa73f5d 100644 --- a/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java +++ b/src/main/java/com/pipedream/api/resources/filestash/AsyncRawFileStashClient.java @@ -11,9 +11,11 @@ import com.pipedream.api.core.ObjectMappers; import com.pipedream.api.core.QueryStringMapper; import com.pipedream.api.core.RequestOptions; +import com.pipedream.api.core.ResponseBodyInputStream; import com.pipedream.api.errors.TooManyRequestsError; import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest; import java.io.IOException; +import java.io.InputStream; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -35,14 +37,14 @@ public AsyncRawFileStashClient(ClientOptions clientOptions) { /** * Download a file from File Stash */ - public CompletableFuture> downloadFile(FileStashDownloadFileRequest request) { + public CompletableFuture> downloadFile(FileStashDownloadFileRequest request) { return downloadFile(request, null); } /** * Download a file from File Stash */ - public CompletableFuture> downloadFile( + public CompletableFuture> downloadFile( FileStashDownloadFileRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -60,13 +62,14 @@ public CompletableFuture> downloadFile( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { + try { + ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - future.complete(new BaseClientHttpResponse<>(null, response)); + future.complete(new BaseClientHttpResponse<>(new ResponseBodyInputStream(response), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/pipedream/api/resources/filestash/FileStashClient.java b/src/main/java/com/pipedream/api/resources/filestash/FileStashClient.java index f889b1e..3e08288 100644 --- a/src/main/java/com/pipedream/api/resources/filestash/FileStashClient.java +++ b/src/main/java/com/pipedream/api/resources/filestash/FileStashClient.java @@ -6,6 +6,7 @@ import com.pipedream.api.core.ClientOptions; import com.pipedream.api.core.RequestOptions; import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest; +import java.io.InputStream; public class FileStashClient { protected final ClientOptions clientOptions; @@ -27,14 +28,14 @@ public RawFileStashClient withRawResponse() { /** * Download a file from File Stash */ - public void downloadFile(FileStashDownloadFileRequest request) { - this.rawClient.downloadFile(request).body(); + public InputStream downloadFile(FileStashDownloadFileRequest request) { + return this.rawClient.downloadFile(request).body(); } /** * Download a file from File Stash */ - public void downloadFile(FileStashDownloadFileRequest request, RequestOptions requestOptions) { - this.rawClient.downloadFile(request, requestOptions).body(); + public InputStream downloadFile(FileStashDownloadFileRequest request, RequestOptions requestOptions) { + return this.rawClient.downloadFile(request, requestOptions).body(); } } 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 777c227..2bd5052 100644 --- a/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java +++ b/src/main/java/com/pipedream/api/resources/filestash/RawFileStashClient.java @@ -11,9 +11,11 @@ import com.pipedream.api.core.ObjectMappers; import com.pipedream.api.core.QueryStringMapper; import com.pipedream.api.core.RequestOptions; +import com.pipedream.api.core.ResponseBodyInputStream; import com.pipedream.api.errors.TooManyRequestsError; import com.pipedream.api.resources.filestash.requests.FileStashDownloadFileRequest; import java.io.IOException; +import java.io.InputStream; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -31,14 +33,14 @@ public RawFileStashClient(ClientOptions clientOptions) { /** * Download a file from File Stash */ - public BaseClientHttpResponse downloadFile(FileStashDownloadFileRequest request) { + public BaseClientHttpResponse downloadFile(FileStashDownloadFileRequest request) { return downloadFile(request, null); } /** * Download a file from File Stash */ - public BaseClientHttpResponse downloadFile( + public BaseClientHttpResponse downloadFile( FileStashDownloadFileRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -56,10 +58,11 @@ public BaseClientHttpResponse downloadFile( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - try (Response response = client.newCall(okhttpRequest).execute()) { + try { + Response response = client.newCall(okhttpRequest).execute(); ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - return new BaseClientHttpResponse<>(null, response); + return new BaseClientHttpResponse<>(new ResponseBodyInputStream(response), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/pipedream/api/resources/oauthtokens/requests/CreateOAuthTokenOpts.java b/src/main/java/com/pipedream/api/resources/oauthtokens/requests/CreateOAuthTokenOpts.java index 50ab4b2..191f8cb 100644 --- a/src/main/java/com/pipedream/api/resources/oauthtokens/requests/CreateOAuthTokenOpts.java +++ b/src/main/java/com/pipedream/api/resources/oauthtokens/requests/CreateOAuthTokenOpts.java @@ -9,11 +9,13 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -23,11 +25,15 @@ public final class CreateOAuthTokenOpts { private final String clientSecret; + private final Optional scope; + private final Map additionalProperties; - private CreateOAuthTokenOpts(String clientId, String clientSecret, Map additionalProperties) { + private CreateOAuthTokenOpts( + String clientId, String clientSecret, Optional scope, Map additionalProperties) { this.clientId = clientId; this.clientSecret = clientSecret; + this.scope = scope; this.additionalProperties = additionalProperties; } @@ -46,6 +52,14 @@ public String getClientSecret() { return clientSecret; } + /** + * @return Optional space-separated scopes for the access token. Defaults to '*'. + */ + @JsonProperty("scope") + public Optional getScope() { + return scope; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -58,12 +72,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateOAuthTokenOpts other) { - return clientId.equals(other.clientId) && clientSecret.equals(other.clientSecret); + return clientId.equals(other.clientId) && clientSecret.equals(other.clientSecret) && scope.equals(other.scope); } @java.lang.Override public int hashCode() { - return Objects.hash(this.clientId, this.clientSecret); + return Objects.hash(this.clientId, this.clientSecret, this.scope); } @java.lang.Override @@ -87,6 +101,13 @@ public interface ClientSecretStage { public interface _FinalStage { CreateOAuthTokenOpts build(); + + /** + *

Optional space-separated scopes for the access token. Defaults to '*'.

+ */ + _FinalStage scope(Optional scope); + + _FinalStage scope(String scope); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -95,6 +116,8 @@ public static final class Builder implements ClientIdStage, ClientSecretStage, _ private String clientSecret; + private Optional scope = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -104,6 +127,7 @@ private Builder() {} public Builder from(CreateOAuthTokenOpts other) { clientId(other.getClientId()); clientSecret(other.getClientSecret()); + scope(other.getScope()); return this; } @@ -121,9 +145,29 @@ public _FinalStage clientSecret(@NotNull String clientSecret) { return this; } + /** + *

Optional space-separated scopes for the access token. Defaults to '*'.

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

Optional space-separated scopes for the access token. Defaults to '*'.

+ */ + @java.lang.Override + @JsonSetter(value = "scope", nulls = Nulls.SKIP) + public _FinalStage scope(Optional scope) { + this.scope = scope; + return this; + } + @java.lang.Override public CreateOAuthTokenOpts build() { - return new CreateOAuthTokenOpts(clientId, clientSecret, additionalProperties); + return new CreateOAuthTokenOpts(clientId, clientSecret, scope, additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java index bb0aa7f..d37deb9 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/AsyncProxyClient.java @@ -10,7 +10,6 @@ import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest; import com.pipedream.api.resources.proxy.requests.ProxyPostRequest; import com.pipedream.api.resources.proxy.requests.ProxyPutRequest; -import java.util.Base64; import java.util.concurrent.CompletableFuture; public class AsyncProxyClient { @@ -30,57 +29,73 @@ public AsyncRawProxyClient withRawResponse() { return this.rawClient; } - private String encodeUrl(String url) { - return Base64.getUrlEncoder().encodeToString(url.getBytes()); - } - - public CompletableFuture get(String url, ProxyGetRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ + public CompletableFuture get(String url64, ProxyGetRequest request) { return this.rawClient.get(url64, request).thenApply(response -> response.body()); } - public CompletableFuture get(String url, ProxyGetRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ + public CompletableFuture get(String url64, ProxyGetRequest request, RequestOptions requestOptions) { return this.rawClient.get(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture post(String url, ProxyPostRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ + public CompletableFuture post(String url64, ProxyPostRequest request) { return this.rawClient.post(url64, request).thenApply(response -> response.body()); } - public CompletableFuture post(String url, ProxyPostRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ + public CompletableFuture post(String url64, ProxyPostRequest request, RequestOptions requestOptions) { return this.rawClient.post(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture put(String url, ProxyPutRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ + public CompletableFuture put(String url64, ProxyPutRequest request) { return this.rawClient.put(url64, request).thenApply(response -> response.body()); } - public CompletableFuture put(String url, ProxyPutRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ + public CompletableFuture put(String url64, ProxyPutRequest request, RequestOptions requestOptions) { return this.rawClient.put(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture delete(String url, ProxyDeleteRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ + public CompletableFuture delete(String url64, ProxyDeleteRequest request) { return this.rawClient.delete(url64, request).thenApply(response -> response.body()); } - public CompletableFuture delete(String url, ProxyDeleteRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ + public CompletableFuture delete(String url64, ProxyDeleteRequest request, RequestOptions requestOptions) { return this.rawClient.delete(url64, request, requestOptions).thenApply(response -> response.body()); } - public CompletableFuture patch(String url, ProxyPatchRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ + public CompletableFuture patch(String url64, ProxyPatchRequest request) { return this.rawClient.patch(url64, request).thenApply(response -> response.body()); } - public CompletableFuture patch(String url, ProxyPatchRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ + public CompletableFuture patch(String url64, ProxyPatchRequest request, RequestOptions requestOptions) { return this.rawClient.patch(url64, request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java index 491d03f..74bc677 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/AsyncRawProxyClient.java @@ -3,6 +3,7 @@ */ package com.pipedream.api.resources.proxy; +import com.fasterxml.jackson.core.JsonProcessingException; import com.pipedream.api.core.BaseClientApiException; import com.pipedream.api.core.BaseClientException; import com.pipedream.api.core.BaseClientHttpResponse; @@ -11,6 +12,7 @@ import com.pipedream.api.core.ObjectMappers; import com.pipedream.api.core.QueryStringMapper; import com.pipedream.api.core.RequestOptions; +import com.pipedream.api.errors.TooManyRequestsError; import com.pipedream.api.resources.proxy.requests.ProxyDeleteRequest; import com.pipedream.api.resources.proxy.requests.ProxyGetRequest; import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest; @@ -36,21 +38,16 @@ public AsyncRawProxyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - private Object parseResponse(String responseBodyString) { - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - return null; - } - try { - return ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception jsonException) { - return responseBodyString; - } - } - + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ public CompletableFuture> get(String url64, ProxyGetRequest request) { return get(url64, request, null); } + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ public CompletableFuture> get( String url64, ProxyGetRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -77,21 +74,24 @@ public CompletableFuture> get( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null - || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -107,10 +107,16 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ public CompletableFuture> post(String url64, ProxyPostRequest request) { return post(url64, request, null); } + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ public CompletableFuture> post( String url64, ProxyPostRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -145,21 +151,24 @@ public CompletableFuture> post( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null - || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -175,10 +184,16 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ public CompletableFuture> put(String url64, ProxyPutRequest request) { return put(url64, request, null); } + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ public CompletableFuture> put( String url64, ProxyPutRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -213,21 +228,24 @@ public CompletableFuture> put( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null - || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -243,10 +261,16 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ public CompletableFuture> delete(String url64, ProxyDeleteRequest request) { return delete(url64, request, null); } + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ public CompletableFuture> delete( String url64, ProxyDeleteRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -273,21 +297,24 @@ public CompletableFuture> delete( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null - || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { @@ -303,10 +330,16 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ public CompletableFuture> patch(String url64, ProxyPatchRequest request) { return patch(url64, request, null); } + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ public CompletableFuture> patch( String url64, ProxyPatchRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -341,21 +374,24 @@ public CompletableFuture> patch( public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - if (responseBodyString == null - || responseBodyString.trim().isEmpty()) { - future.complete(new BaseClientHttpResponse<>(null, response)); - return; - } - Object parsedResponse = parseResponse(responseBodyString); - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); + future.complete(new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); return; } catch (IOException e) { diff --git a/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java index 0e4781b..a532d9b 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/ProxyClient.java @@ -10,7 +10,6 @@ import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest; import com.pipedream.api.resources.proxy.requests.ProxyPostRequest; import com.pipedream.api.resources.proxy.requests.ProxyPutRequest; -import java.util.Base64; public class ProxyClient { protected final ClientOptions clientOptions; @@ -29,57 +28,73 @@ public RawProxyClient withRawResponse() { return this.rawClient; } - private String encodeUrl(String url) { - return Base64.getUrlEncoder().encodeToString(url.getBytes()); - } - - public Object get(String url, ProxyGetRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ + public Object get(String url64, ProxyGetRequest request) { return this.rawClient.get(url64, request).body(); } - public Object get(String url, ProxyGetRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ + public Object get(String url64, ProxyGetRequest request, RequestOptions requestOptions) { return this.rawClient.get(url64, request, requestOptions).body(); } - public Object post(String url, ProxyPostRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ + public Object post(String url64, ProxyPostRequest request) { return this.rawClient.post(url64, request).body(); } - public Object post(String url, ProxyPostRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ + public Object post(String url64, ProxyPostRequest request, RequestOptions requestOptions) { return this.rawClient.post(url64, request, requestOptions).body(); } - public Object put(String url, ProxyPutRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ + public Object put(String url64, ProxyPutRequest request) { return this.rawClient.put(url64, request).body(); } - public Object put(String url, ProxyPutRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ + public Object put(String url64, ProxyPutRequest request, RequestOptions requestOptions) { return this.rawClient.put(url64, request, requestOptions).body(); } - public Object delete(String url, ProxyDeleteRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ + public Object delete(String url64, ProxyDeleteRequest request) { return this.rawClient.delete(url64, request).body(); } - public Object delete(String url, ProxyDeleteRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ + public Object delete(String url64, ProxyDeleteRequest request, RequestOptions requestOptions) { return this.rawClient.delete(url64, request, requestOptions).body(); } - public Object patch(String url, ProxyPatchRequest request) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ + public Object patch(String url64, ProxyPatchRequest request) { return this.rawClient.patch(url64, request).body(); } - public Object patch(String url, ProxyPatchRequest request, RequestOptions requestOptions) { - final String url64 = encodeUrl(url); + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ + public Object patch(String url64, ProxyPatchRequest request, RequestOptions requestOptions) { return this.rawClient.patch(url64, request, requestOptions).body(); } } diff --git a/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java b/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java index 7e75266..1388ed6 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java +++ b/src/main/java/com/pipedream/api/resources/proxy/RawProxyClient.java @@ -3,6 +3,7 @@ */ package com.pipedream.api.resources.proxy; +import com.fasterxml.jackson.core.JsonProcessingException; import com.pipedream.api.core.BaseClientApiException; import com.pipedream.api.core.BaseClientException; import com.pipedream.api.core.BaseClientHttpResponse; @@ -11,6 +12,7 @@ import com.pipedream.api.core.ObjectMappers; import com.pipedream.api.core.QueryStringMapper; import com.pipedream.api.core.RequestOptions; +import com.pipedream.api.errors.TooManyRequestsError; import com.pipedream.api.resources.proxy.requests.ProxyDeleteRequest; import com.pipedream.api.resources.proxy.requests.ProxyGetRequest; import com.pipedream.api.resources.proxy.requests.ProxyPatchRequest; @@ -32,21 +34,16 @@ public RawProxyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - private Object parseResponse(String responseBodyString) { - if (responseBodyString == null || responseBodyString.trim().isEmpty()) { - return null; - } - try { - return ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception jsonException) { - return responseBodyString; - } - } - + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ public BaseClientHttpResponse get(String url64, ProxyGetRequest request) { return get(url64, request, null); } + /** + * Forward an authenticated GET request to an external API using an external user's account credentials + */ public BaseClientHttpResponse get(String url64, ProxyGetRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -69,25 +66,38 @@ public BaseClientHttpResponse get(String url64, ProxyGetRequest request, try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } } + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ public BaseClientHttpResponse post(String url64, ProxyPostRequest request) { return post(url64, request, null); } + /** + * Forward an authenticated POST request to an external API using an external user's account credentials + */ public BaseClientHttpResponse post(String url64, ProxyPostRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -118,25 +128,38 @@ public BaseClientHttpResponse post(String url64, ProxyPostRequest reques try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } } + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ public BaseClientHttpResponse put(String url64, ProxyPutRequest request) { return put(url64, request, null); } + /** + * Forward an authenticated PUT request to an external API using an external user's account credentials + */ public BaseClientHttpResponse put(String url64, ProxyPutRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -167,25 +190,38 @@ public BaseClientHttpResponse put(String url64, ProxyPutRequest request, try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } } + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ public BaseClientHttpResponse delete(String url64, ProxyDeleteRequest request) { return delete(url64, request, null); } + /** + * Forward an authenticated DELETE request to an external API using an external user's account credentials + */ public BaseClientHttpResponse delete( String url64, ProxyDeleteRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -209,25 +245,38 @@ public BaseClientHttpResponse delete( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); } } + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ public BaseClientHttpResponse patch(String url64, ProxyPatchRequest request) { return patch(url64, request, null); } + /** + * Forward an authenticated PATCH request to an external API using an external user's account credentials + */ public BaseClientHttpResponse patch( String url64, ProxyPatchRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -259,15 +308,22 @@ public BaseClientHttpResponse patch( try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : null; - Object parsedResponse = parseResponse(responseBodyString); - return new BaseClientHttpResponse<>(parsedResponse, response); + return new BaseClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Object.class), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 429) { + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } throw new BaseClientApiException( "Error with status code " + response.code(), response.code(), - parseResponse(responseBodyString), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); } catch (IOException e) { throw new BaseClientException("Network error executing HTTP request", e); diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java index fe68355..c221032 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java +++ b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPatchRequest.java @@ -185,7 +185,9 @@ public _FinalStage body(String key, Object value) { */ @java.lang.Override public _FinalStage putAllBody(Map body) { - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } @@ -196,7 +198,9 @@ public _FinalStage putAllBody(Map body) { @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Map body) { this.body.clear(); - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java index d648ab4..3c052fd 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java +++ b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPostRequest.java @@ -185,7 +185,9 @@ public _FinalStage body(String key, Object value) { */ @java.lang.Override public _FinalStage putAllBody(Map body) { - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } @@ -196,7 +198,9 @@ public _FinalStage putAllBody(Map body) { @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Map body) { this.body.clear(); - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } diff --git a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java index d4aaeba..9ba3dc8 100644 --- a/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java +++ b/src/main/java/com/pipedream/api/resources/proxy/requests/ProxyPutRequest.java @@ -185,7 +185,9 @@ public _FinalStage body(String key, Object value) { */ @java.lang.Override public _FinalStage putAllBody(Map body) { - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } @@ -196,7 +198,9 @@ public _FinalStage putAllBody(Map body) { @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Map body) { this.body.clear(); - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } 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 02b9ac8..4facd5c 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/triggers/AsyncRawTriggersClient.java @@ -116,15 +116,16 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .build(); List result = parsedResponse.getData(); future.complete(new BaseClientHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return list(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } 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 a60a957..68a8a22 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java +++ b/src/main/java/com/pipedream/api/resources/triggers/RawTriggersClient.java @@ -107,9 +107,9 @@ public BaseClientHttpResponse> list( .build(); List result = parsedResponse.getData(); return new BaseClientHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) + .body()), response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; diff --git a/src/main/java/com/pipedream/api/resources/triggers/requests/DeployTriggerOpts.java b/src/main/java/com/pipedream/api/resources/triggers/requests/DeployTriggerOpts.java index 8e151d3..edce315 100644 --- a/src/main/java/com/pipedream/api/resources/triggers/requests/DeployTriggerOpts.java +++ b/src/main/java/com/pipedream/api/resources/triggers/requests/DeployTriggerOpts.java @@ -30,6 +30,8 @@ public final class DeployTriggerOpts { private final Optional dynamicPropsId; + private final Optional workflowId; + private final Optional webhookUrl; private final Map additionalProperties; @@ -39,12 +41,14 @@ private DeployTriggerOpts( String externalUserId, Optional> configuredProps, Optional dynamicPropsId, + Optional workflowId, Optional webhookUrl, Map additionalProperties) { this.id = id; this.externalUserId = externalUserId; this.configuredProps = configuredProps; this.dynamicPropsId = dynamicPropsId; + this.workflowId = workflowId; this.webhookUrl = webhookUrl; this.additionalProperties = additionalProperties; } @@ -78,6 +82,14 @@ public Optional getDynamicPropsId() { return dynamicPropsId; } + /** + * @return Optional ID of a workflow to receive trigger events + */ + @JsonProperty("workflow_id") + public Optional getWorkflowId() { + return workflowId; + } + /** * @return Optional webhook URL to receive trigger events */ @@ -102,12 +114,19 @@ private boolean equalTo(DeployTriggerOpts other) { && externalUserId.equals(other.externalUserId) && configuredProps.equals(other.configuredProps) && dynamicPropsId.equals(other.dynamicPropsId) + && workflowId.equals(other.workflowId) && webhookUrl.equals(other.webhookUrl); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.externalUserId, this.configuredProps, this.dynamicPropsId, this.webhookUrl); + return Objects.hash( + this.id, + this.externalUserId, + this.configuredProps, + this.dynamicPropsId, + this.workflowId, + this.webhookUrl); } @java.lang.Override @@ -149,6 +168,13 @@ public interface _FinalStage { _FinalStage dynamicPropsId(String dynamicPropsId); + /** + *

Optional ID of a workflow to receive trigger events

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

Optional webhook URL to receive trigger events

*/ @@ -165,6 +191,8 @@ public static final class Builder implements IdStage, ExternalUserIdStage, _Fina private Optional webhookUrl = Optional.empty(); + private Optional workflowId = Optional.empty(); + private Optional dynamicPropsId = Optional.empty(); private Optional> configuredProps = Optional.empty(); @@ -180,6 +208,7 @@ public Builder from(DeployTriggerOpts other) { externalUserId(other.getExternalUserId()); configuredProps(other.getConfiguredProps()); dynamicPropsId(other.getDynamicPropsId()); + workflowId(other.getWorkflowId()); webhookUrl(other.getWebhookUrl()); return this; } @@ -228,6 +257,26 @@ public _FinalStage webhookUrl(Optional webhookUrl) { return this; } + /** + *

Optional ID of a workflow to receive trigger events

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

Optional ID of a workflow to receive trigger events

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

The ID for dynamic props

* @return Reference to {@code this} so that method calls can be chained together. @@ -264,7 +313,7 @@ public _FinalStage configuredProps(Optional> co @java.lang.Override public DeployTriggerOpts build() { return new DeployTriggerOpts( - id, externalUserId, configuredProps, dynamicPropsId, webhookUrl, additionalProperties); + id, externalUserId, configuredProps, dynamicPropsId, workflowId, webhookUrl, additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java deleted file mode 100644 index d523b9d..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/AsyncRawWorkflowsClient.java +++ /dev/null @@ -1,268 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows; - -import com.pipedream.api.core.BaseClientApiException; -import com.pipedream.api.core.BaseClientException; -import com.pipedream.api.core.BaseClientHttpResponse; -import com.pipedream.api.core.ClientOptions; -import com.pipedream.api.core.MediaTypes; -import com.pipedream.api.core.ObjectMappers; -import com.pipedream.api.core.RequestOptions; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts; -import com.pipedream.api.types.HTTPAuthType; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class AsyncRawWorkflowsClient { - protected final ClientOptions clientOptions; - private final String workflowDomain; - private final String urlProtocol; - - public AsyncRawWorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.workflowDomain = getDefaultWorkflowDomain(); - this.urlProtocol = getUrlProtocol(); - } - - public CompletableFuture> invoke(InvokeWorkflowOpts request) { - return invoke(request, null); - } - - public CompletableFuture> invoke( - InvokeWorkflowOpts request, RequestOptions requestOptions) { - - // Build the workflow URL - String urlString = buildWorkflowUrl(request.getUrlOrEndpoint()); - - HttpUrl httpUrl; - try { - httpUrl = HttpUrl.parse(urlString); - if (httpUrl == null) { - throw new IllegalArgumentException("Invalid URL: " + urlString); - } - } catch (Exception e) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new IllegalArgumentException("Invalid URL: " + urlString, e)); - return future; - } - - // Determine auth type - default to OAuth if not specified - HTTPAuthType authType = request.getAuthType().orElse(HTTPAuthType.OAUTH); - - // Prepare headers - start with client options headers (includes OAuth auth if configured) - Map allHeaders = new HashMap<>(clientOptions.headers(requestOptions)); - - // Handle authentication based on type - if (authType == HTTPAuthType.OAUTH) { - // For OAuth, the Authorization header should already be in clientOptions.headers() - // No additional action needed - } else if (authType == HTTPAuthType.STATIC_BEARER) { - // For static_bearer, users must provide the Authorization header in request.getHeaders() - // Their header will override any existing OAuth header when we merge request headers - } else if (authType == HTTPAuthType.NONE) { - // For NONE auth type, set Authorization header to empty string (matches Python SDK) - allHeaders.put("Authorization", ""); - } - - // Add request-specific headers (can override auth headers for STATIC_BEARER) - if (request.getHeaders().isPresent()) { - allHeaders.putAll(request.getHeaders().get()); - } - - // Determine HTTP method - String method = request.getMethod().orElse("POST").toUpperCase(); - - // Prepare request body if needed - RequestBody body = null; - if (request.getBody().isPresent()) { - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes( - request.getBody().get()), - MediaTypes.APPLICATION_JSON); - allHeaders.put("Content-Type", "application/json"); - } catch (Exception e) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new RuntimeException("Failed to serialize request body", e)); - return future; - } - } else if (("POST".equals(method) || "PUT".equals(method) || "PATCH".equals(method))) { - // For methods that typically require a body, send an empty body - // to avoid OkHttp's "method POST must have a request body" error - body = RequestBody.create(new byte[0], null); - } - - // Build the request - Request.Builder requestBuilder = - new Request.Builder().url(httpUrl).method(method, body).headers(Headers.of(allHeaders)); - - if (!allHeaders.containsKey("Accept")) { - requestBuilder.addHeader("Accept", "application/json"); - } - - Request okhttpRequest = requestBuilder.build(); - - // Execute the request asynchronously - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - - CompletableFuture> future = new CompletableFuture<>(); - - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - future.completeExceptionally(new BaseClientException("Network error executing HTTP request", e)); - } - - @Override - public void onResponse(Call call, Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - Object parsedResponse; - try { - parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception e) { - // If JSON parsing fails, return the raw string - parsedResponse = responseBodyString; - } - future.complete(new BaseClientHttpResponse<>(parsedResponse, response)); - } else { - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - future.completeExceptionally(new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - } - } catch (Exception e) { - future.completeExceptionally(e); - } - } - }); - - return future; - } - - public CompletableFuture> invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request) { - return invokeForExternalUser(request, null); - } - - public CompletableFuture> invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - - // Validate inputs - if (request.getExternalUserId() == null - || request.getExternalUserId().trim().isEmpty()) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new IllegalArgumentException("External user ID is required")); - return future; - } - - if (request.getUrl() == null || request.getUrl().trim().isEmpty()) { - CompletableFuture> future = new CompletableFuture<>(); - future.completeExceptionally(new IllegalArgumentException("Workflow URL is required")); - return future; - } - - // Prepare headers with external user ID - Map headers = new HashMap<>(); - if (request.getHeaders().isPresent()) { - headers.putAll(request.getHeaders().get()); - } - headers.put("X-PD-External-User-ID", request.getExternalUserId()); - - // Create a new request with the authentication from the original request and the external user header - InvokeWorkflowOpts invokeRequest = InvokeWorkflowOpts.builder() - .urlOrEndpoint(request.getUrl()) - .body(request.getBody()) - .headers(headers) - .method(request.getMethod()) - .authType(request.getAuthType().orElse(HTTPAuthType.OAUTH)) - .build(); - - return invoke(invokeRequest, requestOptions); - } - - /** - * Builds a full workflow URL based on the input. - * - * @param input Either a full URL (with or without protocol) or just an endpoint ID. - * @return The fully constructed URL. - */ - private String buildWorkflowUrl(String input) { - String sanitizedInput = input.trim().toLowerCase(); - if (sanitizedInput.isEmpty()) { - throw new IllegalArgumentException("URL or endpoint ID is required"); - } - - // Check if it's already a full URL - if (sanitizedInput.startsWith("http://") || sanitizedInput.startsWith("https://")) { - try { - URL url = new URL(input); - // Validate the hostname - String workflowDomain = this.workflowDomain; - if (!url.getHost().endsWith(this.workflowDomain)) { - throw new IllegalArgumentException( - "Invalid workflow domain. URL must end with " + this.workflowDomain); - } - return input; - } catch (MalformedURLException e) { - throw new IllegalArgumentException("The provided URL is malformed: " + input, e); - } - } - - // Check if it's a URL without protocol - if (sanitizedInput.contains(".")) { - return buildWorkflowUrl("https://" + input); - } - - // It's an endpoint ID - if (!sanitizedInput.matches("^e[no][a-z0-9-]+$")) { - throw new IllegalArgumentException( - "Invalid endpoint ID format. Must contain only letters, numbers, and hyphens, " - + "and start with either 'en' or 'eo'."); - } - - return urlProtocol + "://" + sanitizedInput + "." + workflowDomain; - } - - private String getDefaultWorkflowDomain() { - String envUrl = clientOptions.environment().getUrl(); - // For non-prod environments (dev, staging), use dev domain - if (!envUrl.equals("https://api.pipedream.com") && !envUrl.equals("https://api2.pipedream.com")) { - return "m.d.pipedream.net"; - } - // For prod and canary, use standard domain - return "m.pipedream.net"; - } - - private String getUrlProtocol() { - String envUrl = clientOptions.environment().getUrl(); - // For non-prod environments (dev, staging), use http - if (!envUrl.equals("https://api.pipedream.com") && !envUrl.equals("https://api2.pipedream.com")) { - return "http"; - } - // For prod and canary, use https - return "https"; - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/AsyncWorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/AsyncWorkflowsClient.java deleted file mode 100644 index 08f9081..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/AsyncWorkflowsClient.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows; - -import com.pipedream.api.core.ClientOptions; -import com.pipedream.api.core.RequestOptions; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts; -import java.util.concurrent.CompletableFuture; - -public class AsyncWorkflowsClient { - protected final ClientOptions clientOptions; - - private final AsyncRawWorkflowsClient rawClient; - - public AsyncWorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawWorkflowsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawWorkflowsClient withRawResponse() { - return this.rawClient; - } - - /** - * Invokes a workflow using the URL of its HTTP interface(s). - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @return A future containing the response from the workflow - */ - public CompletableFuture invoke(String urlOrEndpoint) { - InvokeWorkflowOpts request = - InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build(); - return this.rawClient.invoke(request).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow using the URL of its HTTP interface(s). - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @param requestOptions Additional request options - * @return A future containing the response from the workflow - */ - public CompletableFuture invoke(String urlOrEndpoint, RequestOptions requestOptions) { - InvokeWorkflowOpts request = - InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build(); - return this.rawClient.invoke(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow using the InvokeWorkflowOpts request object. - * - * @param request The request containing workflow invocation parameters - * @return A future containing the response from the workflow - */ - public CompletableFuture invoke(InvokeWorkflowOpts request) { - return this.rawClient.invoke(request).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow using the InvokeWorkflowOpts request object. - * - * @param request The request containing workflow invocation parameters - * @param requestOptions Additional request options - * @return A future containing the response from the workflow - */ - public CompletableFuture invoke(InvokeWorkflowOpts request, RequestOptions requestOptions) { - return this.rawClient.invoke(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow for a Pipedream Connect user in a project. - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @param externalUserId Your end user ID, for whom you're invoking the workflow - * @return A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser(String urlOrEndpoint, String externalUserId) { - InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder() - .url(urlOrEndpoint) - .externalUserId(externalUserId) - .build(); - return this.rawClient.invokeForExternalUser(request).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow for a Pipedream Connect user in a project. - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @param externalUserId Your end user ID, for whom you're invoking the workflow - * @param requestOptions Additional request options - * @return A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser( - String urlOrEndpoint, String externalUserId, RequestOptions requestOptions) { - InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder() - .url(urlOrEndpoint) - .externalUserId(externalUserId) - .build(); - return this.rawClient.invokeForExternalUser(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object. - * - * @param request The request containing workflow invocation parameters - * @return A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser(InvokeWorkflowForExternalUserOpts request) { - return this.rawClient.invokeForExternalUser(request).thenApply(response -> response.body()); - } - - /** - * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object. - * - * @param request The request containing workflow invocation parameters - * @param requestOptions Additional request options - * @return A future containing the response from the workflow - */ - public CompletableFuture invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - return this.rawClient.invokeForExternalUser(request, requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java deleted file mode 100644 index f48397c..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/RawWorkflowsClient.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows; - -import com.pipedream.api.core.BaseClientApiException; -import com.pipedream.api.core.BaseClientException; -import com.pipedream.api.core.BaseClientHttpResponse; -import com.pipedream.api.core.ClientOptions; -import com.pipedream.api.core.MediaTypes; -import com.pipedream.api.core.ObjectMappers; -import com.pipedream.api.core.RequestOptions; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts; -import com.pipedream.api.types.HTTPAuthType; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawWorkflowsClient { - protected final ClientOptions clientOptions; - private final String workflowDomain; - private final String urlProtocol; - - public RawWorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.workflowDomain = getDefaultWorkflowDomain(); - this.urlProtocol = getUrlProtocol(); - } - - public BaseClientHttpResponse invoke(InvokeWorkflowOpts request) { - return invoke(request, null); - } - - public BaseClientHttpResponse invoke(InvokeWorkflowOpts request, RequestOptions requestOptions) { - // Build the workflow URL - String urlString = buildWorkflowUrl(request.getUrlOrEndpoint()); - - HttpUrl httpUrl; - try { - httpUrl = HttpUrl.parse(urlString); - if (httpUrl == null) { - throw new IllegalArgumentException("Invalid URL: " + urlString); - } - } catch (Exception e) { - throw new IllegalArgumentException("Invalid URL: " + urlString, e); - } - - // Determine auth type - default to OAuth if not specified - HTTPAuthType authType = request.getAuthType().orElse(HTTPAuthType.OAUTH); - - // Prepare headers - start with client options headers (includes OAuth auth if configured) - Map allHeaders = new HashMap<>(clientOptions.headers(requestOptions)); - - // Handle authentication based on type - if (authType == HTTPAuthType.OAUTH) { - // For OAuth, the Authorization header should already be in clientOptions.headers() - // No additional action needed - } else if (authType == HTTPAuthType.STATIC_BEARER) { - // For static_bearer, users must provide the Authorization header in request.getHeaders() - // Their header will override any existing OAuth header when we merge request headers - } else if (authType == HTTPAuthType.NONE) { - // For NONE auth type, set Authorization header to empty string (matches Python SDK) - allHeaders.put("Authorization", ""); - } - - // Add request-specific headers (can override auth headers for STATIC_BEARER) - if (request.getHeaders().isPresent()) { - allHeaders.putAll(request.getHeaders().get()); - } - - // Determine HTTP method - String method = request.getMethod().orElse("POST").toUpperCase(); - - // Prepare request body if needed - RequestBody body = null; - if (request.getBody().isPresent()) { - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes( - request.getBody().get()), - MediaTypes.APPLICATION_JSON); - allHeaders.put("Content-Type", "application/json"); - } catch (Exception e) { - throw new RuntimeException("Failed to serialize request body", e); - } - } else if (("POST".equals(method) || "PUT".equals(method) || "PATCH".equals(method))) { - // For methods that typically require a body, send an empty body - // to avoid OkHttp's "method POST must have a request body" error - body = RequestBody.create(new byte[0], null); - } - - // Build the request - Request.Builder requestBuilder = - new Request.Builder().url(httpUrl).method(method, body).headers(Headers.of(allHeaders)); - - if (!allHeaders.containsKey("Accept")) { - requestBuilder.addHeader("Accept", "application/json"); - } - - Request okhttpRequest = requestBuilder.build(); - - // Execute the request - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - Object parsedResponse; - try { - parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class); - } catch (Exception e) { - // If JSON parsing fails, return the raw string - parsedResponse = responseBodyString; - } - return new BaseClientHttpResponse<>(parsedResponse, response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new BaseClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new BaseClientException("Network error executing HTTP request", e); - } - } - - public BaseClientHttpResponse invokeForExternalUser(InvokeWorkflowForExternalUserOpts request) { - return invokeForExternalUser(request, null); - } - - public BaseClientHttpResponse invokeForExternalUser( - InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - - // Validate inputs - if (request.getExternalUserId() == null - || request.getExternalUserId().trim().isEmpty()) { - throw new IllegalArgumentException("External user ID is required"); - } - - if (request.getUrl() == null || request.getUrl().trim().isEmpty()) { - throw new IllegalArgumentException("Workflow URL is required"); - } - - // Prepare headers with external user ID - Map headers = new HashMap<>(); - if (request.getHeaders().isPresent()) { - headers.putAll(request.getHeaders().get()); - } - headers.put("X-PD-External-User-ID", request.getExternalUserId()); - - // Create a new request with the authentication from the original request and the external user header - InvokeWorkflowOpts invokeRequest = InvokeWorkflowOpts.builder() - .urlOrEndpoint(request.getUrl()) - .body(request.getBody()) - .headers(headers) - .method(request.getMethod()) - .authType(request.getAuthType().orElse(HTTPAuthType.OAUTH)) - .build(); - - return invoke(invokeRequest, requestOptions); - } - - /** - * Builds a full workflow URL based on the input. - * - * @param input Either a full URL (with or without protocol) or just an endpoint ID. - * @return The fully constructed URL. - */ - private String buildWorkflowUrl(String input) { - String sanitizedInput = input.trim().toLowerCase(); - if (sanitizedInput.isEmpty()) { - throw new IllegalArgumentException("URL or endpoint ID is required"); - } - - // Check if it's already a full URL - if (sanitizedInput.startsWith("http://") || sanitizedInput.startsWith("https://")) { - try { - URL url = new URL(input); - // Validate the hostname - String workflowDomain = this.workflowDomain; - if (!url.getHost().endsWith(this.workflowDomain)) { - throw new IllegalArgumentException( - "Invalid workflow domain. URL must end with " + this.workflowDomain); - } - return input; - } catch (MalformedURLException e) { - throw new IllegalArgumentException("The provided URL is malformed: " + input, e); - } - } - - // Check if it's a URL without protocol - if (sanitizedInput.contains(".")) { - return buildWorkflowUrl("https://" + input); - } - - // It's an endpoint ID - if (!sanitizedInput.matches("^e[no][a-z0-9-]+$")) { - throw new IllegalArgumentException( - "Invalid endpoint ID format. Must contain only letters, numbers, and hyphens, " - + "and start with either 'en' or 'eo'."); - } - - return urlProtocol + "://" + sanitizedInput + "." + workflowDomain; - } - - private String getDefaultWorkflowDomain() { - String envUrl = clientOptions.environment().getUrl(); - // For non-prod environments (dev, staging), use dev domain - if (!envUrl.equals("https://api.pipedream.com") && !envUrl.equals("https://api2.pipedream.com")) { - return "m.d.pipedream.net"; - } - // For prod and canary, use standard domain - return "m.pipedream.net"; - } - - private String getUrlProtocol() { - String envUrl = clientOptions.environment().getUrl(); - // For non-prod environments (dev, staging), use http - if (!envUrl.equals("https://api.pipedream.com") && !envUrl.equals("https://api2.pipedream.com")) { - return "http"; - } - // For prod and canary, use https - return "https"; - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java b/src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java deleted file mode 100644 index 935ce7d..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/WorkflowsClient.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows; - -import com.pipedream.api.core.ClientOptions; -import com.pipedream.api.core.RequestOptions; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowForExternalUserOpts; -import com.pipedream.api.resources.workflows.requests.InvokeWorkflowOpts; - -public class WorkflowsClient { - protected final ClientOptions clientOptions; - - private final RawWorkflowsClient rawClient; - - public WorkflowsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawWorkflowsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawWorkflowsClient withRawResponse() { - return this.rawClient; - } - - /** - * Invokes a workflow using the URL of its HTTP interface(s). - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @return The response from the workflow - */ - public Object invoke(String urlOrEndpoint) { - InvokeWorkflowOpts request = - InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build(); - return this.rawClient.invoke(request).body(); - } - - /** - * Invokes a workflow using the URL of its HTTP interface(s). - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @param requestOptions Additional request options - * @return The response from the workflow - */ - public Object invoke(String urlOrEndpoint, RequestOptions requestOptions) { - InvokeWorkflowOpts request = - InvokeWorkflowOpts.builder().urlOrEndpoint(urlOrEndpoint).build(); - return this.rawClient.invoke(request, requestOptions).body(); - } - - /** - * Invokes a workflow using the InvokeWorkflowOpts request object. - * - * @param request The request containing workflow invocation parameters - * @return The response from the workflow - */ - public Object invoke(InvokeWorkflowOpts request) { - return this.rawClient.invoke(request).body(); - } - - /** - * Invokes a workflow using the InvokeWorkflowOpts request object. - * - * @param request The request containing workflow invocation parameters - * @param requestOptions Additional request options - * @return The response from the workflow - */ - public Object invoke(InvokeWorkflowOpts request, RequestOptions requestOptions) { - return this.rawClient.invoke(request, requestOptions).body(); - } - - /** - * Invokes a workflow for a Pipedream Connect user in a project. - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @param externalUserId Your end user ID, for whom you're invoking the workflow - * @return The response from the workflow - */ - public Object invokeForExternalUser(String urlOrEndpoint, String externalUserId) { - InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder() - .url(urlOrEndpoint) - .externalUserId(externalUserId) - .build(); - return this.rawClient.invokeForExternalUser(request).body(); - } - - /** - * Invokes a workflow for a Pipedream Connect user in a project. - * - * @param urlOrEndpoint The URL of the workflow's HTTP interface, or the ID of the endpoint - * @param externalUserId Your end user ID, for whom you're invoking the workflow - * @param requestOptions Additional request options - * @return The response from the workflow - */ - public Object invokeForExternalUser(String urlOrEndpoint, String externalUserId, RequestOptions requestOptions) { - InvokeWorkflowForExternalUserOpts request = InvokeWorkflowForExternalUserOpts.builder() - .url(urlOrEndpoint) - .externalUserId(externalUserId) - .build(); - return this.rawClient.invokeForExternalUser(request, requestOptions).body(); - } - - /** - * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object. - * - * @param request The request containing workflow invocation parameters - * @return The response from the workflow - */ - public Object invokeForExternalUser(InvokeWorkflowForExternalUserOpts request) { - return this.rawClient.invokeForExternalUser(request).body(); - } - - /** - * Invokes a workflow for a Pipedream Connect user using the InvokeWorkflowForExternalUserOpts request object. - * - * @param request The request containing workflow invocation parameters - * @param requestOptions Additional request options - * @return The response from the workflow - */ - public Object invokeForExternalUser(InvokeWorkflowForExternalUserOpts request, RequestOptions requestOptions) { - return this.rawClient.invokeForExternalUser(request, requestOptions).body(); - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/package-info.java b/src/main/java/com/pipedream/api/resources/workflows/package-info.java deleted file mode 100644 index cbd2a49..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This package contains client classes for invoking Pipedream workflows. - * - *

The workflows package provides functionality to: - *

    - *
  • Invoke workflows using their HTTP interface URLs or endpoint IDs
  • - *
  • Invoke workflows on behalf of external users (Pipedream Connect)
  • - *
  • Support both synchronous and asynchronous invocation patterns
  • - *
- * - *

Example usage: - *

- * // Invoke a workflow
- * Object response = client.workflows().invoke("https://your-workflow.m.pipedream.net",
- *     "POST", Map.of("key", "value"), null, HTTPAuthType.OAUTH);
- *
- * // Invoke a workflow for an external user
- * Object response = client.workflows().invokeForExternalUser(
- *     "https://your-workflow.m.pipedream.net",
- *     "external-user-123",
- *     "POST",
- *     Map.of("data", "payload"),
- *     null
- * );
- * 
- */ -package com.pipedream.api.resources.workflows; diff --git a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java b/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java deleted file mode 100644 index 296fb55..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowForExternalUserOpts.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows.requests; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.pipedream.api.types.HTTPAuthType; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = InvokeWorkflowForExternalUserOpts.Builder.class) -public final class InvokeWorkflowForExternalUserOpts { - private final String url; - - private final String externalUserId; - - private final Optional body; - - private final Optional> headers; - - private final Optional method; - - private final Optional authType; - - private InvokeWorkflowForExternalUserOpts( - String url, - String externalUserId, - Optional body, - Optional> headers, - Optional method, - Optional authType) { - this.url = url; - this.externalUserId = externalUserId; - this.body = body; - this.headers = headers; - this.method = method; - this.authType = authType; - } - - @JsonProperty("url") - public String getUrl() { - return url; - } - - @JsonProperty("externalUserId") - public String getExternalUserId() { - return externalUserId; - } - - @JsonProperty("body") - public Optional getBody() { - return body; - } - - @JsonProperty("headers") - public Optional> getHeaders() { - return headers; - } - - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - @JsonProperty("authType") - public Optional getAuthType() { - return authType; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvokeWorkflowForExternalUserOpts && equalTo((InvokeWorkflowForExternalUserOpts) other); - } - - private boolean equalTo(InvokeWorkflowForExternalUserOpts other) { - return url.equals(other.url) - && externalUserId.equals(other.externalUserId) - && body.equals(other.body) - && headers.equals(other.headers) - && method.equals(other.method) - && authType.equals(other.authType); - } - - @Override - public int hashCode() { - return Objects.hash(this.url, this.externalUserId, this.body, this.headers, this.method, this.authType); - } - - @Override - public String toString() { - return "InvokeWorkflowForExternalUserOpts{url: " + url + ", externalUserId: " + externalUserId + ", body: " - + body + ", headers: " + headers + ", method: " + method + ", authType: " + authType + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private String url; - - private String externalUserId; - - private Optional body = Optional.empty(); - - private Optional> headers = Optional.empty(); - - private Optional method = Optional.empty(); - - private Optional authType = Optional.empty(); - - private Builder() {} - - @JsonSetter("url") - public Builder url(String url) { - this.url = url; - return this; - } - - @JsonSetter("externalUserId") - public Builder externalUserId(String externalUserId) { - this.externalUserId = externalUserId; - return this; - } - - @JsonSetter(value = "body", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder body(Optional body) { - this.body = body; - return this; - } - - public Builder body(Object body) { - this.body = Optional.ofNullable(body); - return this; - } - - @JsonSetter(value = "headers", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder headers(Optional> headers) { - this.headers = headers; - return this; - } - - public Builder headers(Map headers) { - this.headers = Optional.ofNullable(headers); - return this; - } - - @JsonSetter(value = "method", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder method(Optional method) { - this.method = method; - return this; - } - - public Builder method(String method) { - this.method = Optional.ofNullable(method); - return this; - } - - @JsonSetter(value = "authType", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder authType(Optional authType) { - this.authType = authType; - return this; - } - - public Builder authType(HTTPAuthType authType) { - this.authType = Optional.ofNullable(authType); - return this; - } - - public InvokeWorkflowForExternalUserOpts build() { - return new InvokeWorkflowForExternalUserOpts(url, externalUserId, body, headers, method, authType); - } - } -} diff --git a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java b/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java deleted file mode 100644 index 468d227..0000000 --- a/src/main/java/com/pipedream/api/resources/workflows/requests/InvokeWorkflowOpts.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.resources.workflows.requests; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.pipedream.api.types.HTTPAuthType; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = InvokeWorkflowOpts.Builder.class) -public final class InvokeWorkflowOpts { - private final String urlOrEndpoint; - - private final Optional body; - - private final Optional> headers; - - private final Optional method; - - private final Optional authType; - - private InvokeWorkflowOpts( - String urlOrEndpoint, - Optional body, - Optional> headers, - Optional method, - Optional authType) { - this.urlOrEndpoint = urlOrEndpoint; - this.body = body; - this.headers = headers; - this.method = method; - this.authType = authType; - } - - @JsonProperty("urlOrEndpoint") - public String getUrlOrEndpoint() { - return urlOrEndpoint; - } - - @JsonProperty("body") - public Optional getBody() { - return body; - } - - @JsonProperty("headers") - public Optional> getHeaders() { - return headers; - } - - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - @JsonProperty("authType") - public Optional getAuthType() { - return authType; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvokeWorkflowOpts && equalTo((InvokeWorkflowOpts) other); - } - - private boolean equalTo(InvokeWorkflowOpts other) { - return urlOrEndpoint.equals(other.urlOrEndpoint) - && body.equals(other.body) - && headers.equals(other.headers) - && method.equals(other.method) - && authType.equals(other.authType); - } - - @Override - public int hashCode() { - return Objects.hash(this.urlOrEndpoint, this.body, this.headers, this.method, this.authType); - } - - @Override - public String toString() { - return "InvokeWorkflowOpts{urlOrEndpoint: " + urlOrEndpoint + ", body: " + body + ", headers: " + headers - + ", method: " + method + ", authType: " + authType + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private String urlOrEndpoint; - - private Optional body = Optional.empty(); - - private Optional> headers = Optional.empty(); - - private Optional method = Optional.empty(); - - private Optional authType = Optional.empty(); - - private Builder() {} - - @JsonSetter("urlOrEndpoint") - public Builder urlOrEndpoint(String urlOrEndpoint) { - this.urlOrEndpoint = urlOrEndpoint; - return this; - } - - @JsonSetter(value = "body", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder body(Optional body) { - this.body = body; - return this; - } - - public Builder body(Object body) { - this.body = Optional.ofNullable(body); - return this; - } - - @JsonSetter(value = "headers", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder headers(Optional> headers) { - this.headers = headers; - return this; - } - - public Builder headers(Map headers) { - this.headers = Optional.ofNullable(headers); - return this; - } - - @JsonSetter(value = "method", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder method(Optional method) { - this.method = method; - return this; - } - - public Builder method(String method) { - this.method = Optional.ofNullable(method); - return this; - } - - @JsonSetter(value = "authType", nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) - public Builder authType(Optional authType) { - this.authType = authType; - return this; - } - - public Builder authType(HTTPAuthType authType) { - this.authType = Optional.ofNullable(authType); - return this; - } - - public InvokeWorkflowOpts build() { - return new InvokeWorkflowOpts(urlOrEndpoint, body, headers, method, authType); - } - } -} diff --git a/src/main/java/com/pipedream/api/types/App.java b/src/main/java/com/pipedream/api/types/App.java index 2ef1869..e2a7888 100644 --- a/src/main/java/com/pipedream/api/types/App.java +++ b/src/main/java/com/pipedream/api/types/App.java @@ -366,7 +366,9 @@ public _FinalStage addCategories(String categories) { @JsonSetter(value = "categories", nulls = Nulls.SKIP) public _FinalStage categories(List categories) { this.categories.clear(); - this.categories.addAll(categories); + if (categories != null) { + this.categories.addAll(categories); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/AppAuthType.java b/src/main/java/com/pipedream/api/types/AppAuthType.java index e795709..965bb0a 100644 --- a/src/main/java/com/pipedream/api/types/AppAuthType.java +++ b/src/main/java/com/pipedream/api/types/AppAuthType.java @@ -3,24 +3,90 @@ */ package com.pipedream.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum AppAuthType { - KEYS("keys"), +public final class AppAuthType { + public static final AppAuthType KEYS = new AppAuthType(Value.KEYS, "keys"); - OAUTH("oauth"), + public static final AppAuthType OAUTH = new AppAuthType(Value.OAUTH, "oauth"); - NONE("none"); + public static final AppAuthType NONE = new AppAuthType(Value.NONE, "none"); - private final String value; + private final Value value; - AppAuthType(String value) { + private final String string; + + AppAuthType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof AppAuthType && this.string.equals(((AppAuthType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case KEYS: + return visitor.visitKeys(); + case OAUTH: + return visitor.visitOauth(); + case NONE: + return visitor.visitNone(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static AppAuthType valueOf(String value) { + switch (value) { + case "keys": + return KEYS; + case "oauth": + return OAUTH; + case "none": + return NONE; + default: + return new AppAuthType(Value.UNKNOWN, value); + } + } + + public enum Value { + KEYS, + + OAUTH, + + NONE, + + UNKNOWN + } + + public interface Visitor { + T visitKeys(); + + T visitOauth(); + + T visitNone(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/types/BackendClientOpts.java b/src/main/java/com/pipedream/api/types/BackendClientOpts.java index cdf9287..1b25323 100644 --- a/src/main/java/com/pipedream/api/types/BackendClientOpts.java +++ b/src/main/java/com/pipedream/api/types/BackendClientOpts.java @@ -26,16 +26,20 @@ public final class BackendClientOpts { private final Optional apiUrl; + private final Optional scope; + private final Map additionalProperties; private BackendClientOpts( Optional clientId, Optional clientSecret, Optional apiUrl, + Optional scope, Map additionalProperties) { this.clientId = clientId; this.clientSecret = clientSecret; this.apiUrl = apiUrl; + this.scope = scope; this.additionalProperties = additionalProperties; } @@ -63,6 +67,14 @@ public Optional getApiUrl() { return apiUrl; } + /** + * @return Optional space-separated scopes for the access token. Defaults to '*'. + */ + @JsonProperty("scope") + public Optional getScope() { + return scope; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -77,12 +89,13 @@ public Map getAdditionalProperties() { private boolean equalTo(BackendClientOpts other) { return clientId.equals(other.clientId) && clientSecret.equals(other.clientSecret) - && apiUrl.equals(other.apiUrl); + && apiUrl.equals(other.apiUrl) + && scope.equals(other.scope); } @java.lang.Override public int hashCode() { - return Objects.hash(this.clientId, this.clientSecret, this.apiUrl); + return Objects.hash(this.clientId, this.clientSecret, this.apiUrl, this.scope); } @java.lang.Override @@ -102,6 +115,8 @@ public static final class Builder { private Optional apiUrl = Optional.empty(); + private Optional scope = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -111,6 +126,7 @@ public Builder from(BackendClientOpts other) { clientId(other.getClientId()); clientSecret(other.getClientSecret()); apiUrl(other.getApiUrl()); + scope(other.getScope()); return this; } @@ -156,8 +172,22 @@ public Builder apiUrl(String apiUrl) { return this; } + /** + *

Optional space-separated scopes for the access token. Defaults to '*'.

+ */ + @JsonSetter(value = "scope", nulls = Nulls.SKIP) + public Builder scope(Optional scope) { + this.scope = scope; + return this; + } + + public Builder scope(String scope) { + this.scope = Optional.ofNullable(scope); + return this; + } + public BackendClientOpts build() { - return new BackendClientOpts(clientId, clientSecret, apiUrl, additionalProperties); + return new BackendClientOpts(clientId, clientSecret, apiUrl, scope, additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/types/Component.java b/src/main/java/com/pipedream/api/types/Component.java index 0521068..c7dcbcc 100644 --- a/src/main/java/com/pipedream/api/types/Component.java +++ b/src/main/java/com/pipedream/api/types/Component.java @@ -37,6 +37,8 @@ public final class Component { private final Optional stash; + private final Optional annotations; + private final Map additionalProperties; private Component( @@ -47,6 +49,7 @@ private Component( Optional description, Optional componentType, Optional stash, + Optional annotations, Map additionalProperties) { this.key = key; this.name = name; @@ -55,6 +58,7 @@ private Component( this.description = description; this.componentType = componentType; this.stash = stash; + this.annotations = annotations; this.additionalProperties = additionalProperties; } @@ -108,6 +112,11 @@ public Optional getStash() { return stash; } + @JsonProperty("annotations") + public Optional getAnnotations() { + return annotations; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -126,7 +135,8 @@ private boolean equalTo(Component other) { && configurableProps.equals(other.configurableProps) && description.equals(other.description) && componentType.equals(other.componentType) - && stash.equals(other.stash); + && stash.equals(other.stash) + && annotations.equals(other.annotations); } @java.lang.Override @@ -138,7 +148,8 @@ public int hashCode() { this.configurableProps, this.description, this.componentType, - this.stash); + this.stash, + this.annotations); } @java.lang.Override @@ -199,6 +210,10 @@ public interface _FinalStage { _FinalStage stash(Optional stash); _FinalStage stash(ComponentStash stash); + + _FinalStage annotations(Optional annotations); + + _FinalStage annotations(ToolAnnotations annotations); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -209,6 +224,8 @@ public static final class Builder implements KeyStage, NameStage, VersionStage, private String version; + private Optional annotations = Optional.empty(); + private Optional stash = Optional.empty(); private Optional componentType = Optional.empty(); @@ -231,6 +248,7 @@ public Builder from(Component other) { description(other.getDescription()); componentType(other.getComponentType()); stash(other.getStash()); + annotations(other.getAnnotations()); return this; } @@ -270,6 +288,19 @@ public _FinalStage version(@NotNull String version) { return this; } + @java.lang.Override + public _FinalStage annotations(ToolAnnotations annotations) { + this.annotations = Optional.ofNullable(annotations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "annotations", nulls = Nulls.SKIP) + public _FinalStage annotations(Optional annotations) { + this.annotations = annotations; + return this; + } + @java.lang.Override public _FinalStage stash(ComponentStash stash) { this.stash = Optional.ofNullable(stash); @@ -341,14 +372,24 @@ public _FinalStage addConfigurableProps(ConfigurableProp configurableProps) { @JsonSetter(value = "configurable_props", nulls = Nulls.SKIP) public _FinalStage configurableProps(List configurableProps) { this.configurableProps.clear(); - this.configurableProps.addAll(configurableProps); + if (configurableProps != null) { + this.configurableProps.addAll(configurableProps); + } return this; } @java.lang.Override public Component build() { return new Component( - key, name, version, configurableProps, description, componentType, stash, additionalProperties); + key, + name, + version, + configurableProps, + description, + componentType, + stash, + annotations, + additionalProperties); } } } diff --git a/src/main/java/com/pipedream/api/types/ComponentStash.java b/src/main/java/com/pipedream/api/types/ComponentStash.java index ffbda73..1ad94c9 100644 --- a/src/main/java/com/pipedream/api/types/ComponentStash.java +++ b/src/main/java/com/pipedream/api/types/ComponentStash.java @@ -3,22 +3,81 @@ */ package com.pipedream.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ComponentStash { - OPTIONAL("optional"), +public final class ComponentStash { + public static final ComponentStash REQUIRED = new ComponentStash(Value.REQUIRED, "required"); - REQUIRED("required"); + public static final ComponentStash OPTIONAL = new ComponentStash(Value.OPTIONAL, "optional"); - private final String value; + private final Value value; - ComponentStash(String value) { + private final String string; + + ComponentStash(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ComponentStash && this.string.equals(((ComponentStash) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case REQUIRED: + return visitor.visitRequired(); + case OPTIONAL: + return visitor.visitOptional(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ComponentStash valueOf(String value) { + switch (value) { + case "required": + return REQUIRED; + case "optional": + return OPTIONAL; + default: + return new ComponentStash(Value.UNKNOWN, value); + } + } + + public enum Value { + OPTIONAL, + + REQUIRED, + + UNKNOWN + } + + public interface Visitor { + T visitOptional(); + + T visitRequired(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/types/ComponentType.java b/src/main/java/com/pipedream/api/types/ComponentType.java index 660d63f..bfd267c 100644 --- a/src/main/java/com/pipedream/api/types/ComponentType.java +++ b/src/main/java/com/pipedream/api/types/ComponentType.java @@ -3,22 +3,81 @@ */ package com.pipedream.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ComponentType { - TRIGGER("trigger"), +public final class ComponentType { + public static final ComponentType TRIGGER = new ComponentType(Value.TRIGGER, "trigger"); - ACTION("action"); + public static final ComponentType ACTION = new ComponentType(Value.ACTION, "action"); - private final String value; + private final Value value; - ComponentType(String value) { + private final String string; + + ComponentType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ComponentType && this.string.equals(((ComponentType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TRIGGER: + return visitor.visitTrigger(); + case ACTION: + return visitor.visitAction(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ComponentType valueOf(String value) { + switch (value) { + case "trigger": + return TRIGGER; + case "action": + return ACTION; + default: + return new ComponentType(Value.UNKNOWN, value); + } + } + + public enum Value { + TRIGGER, + + ACTION, + + UNKNOWN + } + + public interface Visitor { + T visitTrigger(); + + T visitAction(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAlertType.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAlertType.java index 33b65bd..fd72f36 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAlertType.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAlertType.java @@ -3,26 +3,102 @@ */ package com.pipedream.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ConfigurablePropAlertType { - INFO("info"), +public final class ConfigurablePropAlertType { + public static final ConfigurablePropAlertType INFO = new ConfigurablePropAlertType(Value.INFO, "info"); - NEUTRAL("neutral"), + public static final ConfigurablePropAlertType WARNING = new ConfigurablePropAlertType(Value.WARNING, "warning"); - WARNING("warning"), + public static final ConfigurablePropAlertType NEUTRAL = new ConfigurablePropAlertType(Value.NEUTRAL, "neutral"); - ERROR("error"); + public static final ConfigurablePropAlertType ERROR = new ConfigurablePropAlertType(Value.ERROR, "error"); - private final String value; + private final Value value; - ConfigurablePropAlertType(String value) { + private final String string; + + ConfigurablePropAlertType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ConfigurablePropAlertType + && this.string.equals(((ConfigurablePropAlertType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INFO: + return visitor.visitInfo(); + case WARNING: + return visitor.visitWarning(); + case NEUTRAL: + return visitor.visitNeutral(); + case ERROR: + return visitor.visitError(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ConfigurablePropAlertType valueOf(String value) { + switch (value) { + case "info": + return INFO; + case "warning": + return WARNING; + case "neutral": + return NEUTRAL; + case "error": + return ERROR; + default: + return new ConfigurablePropAlertType(Value.UNKNOWN, value); + } + } + + public enum Value { + INFO, + + NEUTRAL, + + WARNING, + + ERROR, + + UNKNOWN + } + + public interface Visitor { + T visitInfo(); + + T visitNeutral(); + + T visitWarning(); + + T visitError(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java index 7794f21..f94d595 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAny.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +22,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigurablePropAny.Builder.class) public final class ConfigurablePropAny { + private final Optional default_; + + private final Optional> options; + private final String name; private final Optional label; @@ -44,6 +49,8 @@ public final class ConfigurablePropAny { private final Map additionalProperties; private ConfigurablePropAny( + Optional default_, + Optional> options, String name, Optional label, Optional description, @@ -55,6 +62,8 @@ private ConfigurablePropAny( Optional reloadProps, Optional withLabel, Map additionalProperties) { + this.default_ = default_; + this.options = options; this.name = name; this.label = label; this.description = description; @@ -73,6 +82,16 @@ public String getType() { return "any"; } + @JsonProperty("default") + public Optional getDefault() { + return default_; + } + + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + /** * @return When building configuredProps, make sure to use this field as the key when setting the prop value */ @@ -165,7 +184,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConfigurablePropAny other) { - return name.equals(other.name) + return default_.equals(other.default_) + && options.equals(other.options) + && name.equals(other.name) && label.equals(other.label) && description.equals(other.description) && optional.equals(other.optional) @@ -180,6 +201,8 @@ private boolean equalTo(ConfigurablePropAny other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.default_, + this.options, this.name, this.label, this.description, @@ -213,6 +236,14 @@ public interface NameStage { public interface _FinalStage { ConfigurablePropAny build(); + _FinalStage default_(Optional default_); + + _FinalStage default_(Object default_); + + _FinalStage options(Optional> options); + + _FinalStage options(List options); + /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

*/ @@ -299,6 +330,10 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); + private Optional> options = Optional.empty(); + + private Optional default_ = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -306,6 +341,8 @@ private Builder() {} @java.lang.Override public Builder from(ConfigurablePropAny other) { + default_(other.getDefault()); + options(other.getOptions()); name(other.getName()); label(other.getLabel()); description(other.getDescription()); @@ -511,9 +548,37 @@ public _FinalStage label(Optional label) { return this; } + @java.lang.Override + public _FinalStage options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + return this; + } + + @java.lang.Override + public _FinalStage default_(Object default_) { + this.default_ = Optional.ofNullable(default_); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default", nulls = Nulls.SKIP) + public _FinalStage default_(Optional default_) { + this.default_ = default_; + return this; + } + @java.lang.Override public ConfigurablePropAny build() { return new ConfigurablePropAny( + default_, + options, name, label, description, diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropAnyOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropAnyOptionsItem.java new file mode 100644 index 0000000..f007b17 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropAnyOptionsItem.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropAnyOptionsItem.Deserializer.class) +public final class ConfigurablePropAnyOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropAnyOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropAnyOptionsItem && equalTo((ConfigurablePropAnyOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropAnyOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropAnyOptionsItem of(PropOption value) { + return new ConfigurablePropAnyOptionsItem(value, 0); + } + + public static ConfigurablePropAnyOptionsItem of(PropOptionNested value) { + return new ConfigurablePropAnyOptionsItem(value, 1); + } + + public static ConfigurablePropAnyOptionsItem of(Optional value) { + return new ConfigurablePropAnyOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropAnyOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropAnyOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java b/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java index cd662cc..8d20484 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropBoolean.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,6 +24,8 @@ public final class ConfigurablePropBoolean { private final Optional default_; + private final Optional> options; + private final String name; private final Optional label; @@ -47,6 +50,7 @@ public final class ConfigurablePropBoolean { private ConfigurablePropBoolean( Optional default_, + Optional> options, String name, Optional label, Optional description, @@ -59,6 +63,7 @@ private ConfigurablePropBoolean( Optional withLabel, Map additionalProperties) { this.default_ = default_; + this.options = options; this.name = name; this.label = label; this.description = description; @@ -77,14 +82,16 @@ public String getType() { return "boolean"; } - /** - * @return The default value for this prop - */ @JsonProperty("default") public Optional getDefault() { return default_; } + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + /** * @return When building configuredProps, make sure to use this field as the key when setting the prop value */ @@ -178,6 +185,7 @@ public Map getAdditionalProperties() { private boolean equalTo(ConfigurablePropBoolean other) { return default_.equals(other.default_) + && options.equals(other.options) && name.equals(other.name) && label.equals(other.label) && description.equals(other.description) @@ -194,6 +202,7 @@ private boolean equalTo(ConfigurablePropBoolean other) { public int hashCode() { return Objects.hash( this.default_, + this.options, this.name, this.label, this.description, @@ -227,13 +236,14 @@ public interface NameStage { public interface _FinalStage { ConfigurablePropBoolean build(); - /** - *

The default value for this prop

- */ _FinalStage default_(Optional default_); _FinalStage default_(Boolean default_); + _FinalStage options(Optional> options); + + _FinalStage options(List options); + /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

*/ @@ -320,6 +330,8 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); + private Optional> options = Optional.empty(); + private Optional default_ = Optional.empty(); @JsonAnySetter @@ -330,6 +342,7 @@ private Builder() {} @java.lang.Override public Builder from(ConfigurablePropBoolean other) { default_(other.getDefault()); + options(other.getOptions()); name(other.getName()); label(other.getLabel()); description(other.getDescription()); @@ -535,19 +548,25 @@ public _FinalStage label(Optional label) { return this; } - /** - *

The default value for this prop

- * @return Reference to {@code this} so that method calls can be chained together. - */ + @java.lang.Override + public _FinalStage options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + return this; + } + @java.lang.Override public _FinalStage default_(Boolean default_) { this.default_ = Optional.ofNullable(default_); return this; } - /** - *

The default value for this prop

- */ @java.lang.Override @JsonSetter(value = "default", nulls = Nulls.SKIP) public _FinalStage default_(Optional default_) { @@ -559,6 +578,7 @@ public _FinalStage default_(Optional default_) { public ConfigurablePropBoolean build() { return new ConfigurablePropBoolean( default_, + options, name, label, description, diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropBooleanOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropBooleanOptionsItem.java new file mode 100644 index 0000000..5d8e3a0 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropBooleanOptionsItem.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropBooleanOptionsItem.Deserializer.class) +public final class ConfigurablePropBooleanOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropBooleanOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropBooleanOptionsItem + && equalTo((ConfigurablePropBooleanOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropBooleanOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropBooleanOptionsItem of(PropOption value) { + return new ConfigurablePropBooleanOptionsItem(value, 0); + } + + public static ConfigurablePropBooleanOptionsItem of(PropOptionNested value) { + return new ConfigurablePropBooleanOptionsItem(value, 1); + } + + public static ConfigurablePropBooleanOptionsItem of(Optional value) { + return new ConfigurablePropBooleanOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropBooleanOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropBooleanOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java b/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java index e50a3b4..5559198 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropInteger.java @@ -26,9 +26,9 @@ public final class ConfigurablePropInteger { private final Optional max; - private final Optional default_; + private final Optional default_; - private final Optional> options; + private final Optional> options; private final String name; @@ -55,8 +55,8 @@ public final class ConfigurablePropInteger { private ConfigurablePropInteger( Optional min, Optional max, - Optional default_, - Optional> options, + Optional default_, + Optional> options, String name, Optional label, Optional description, @@ -106,11 +106,8 @@ public Optional getMax() { return max; } - /** - * @return Default integer value - */ @JsonProperty("default") - public Optional getDefault() { + public Optional getDefault() { return default_; } @@ -118,7 +115,7 @@ public Optional getDefault() { * @return Available integer options */ @JsonProperty("options") - public Optional> getOptions() { + public Optional> getOptions() { return options; } @@ -284,19 +281,16 @@ public interface _FinalStage { _FinalStage max(Integer max); - /** - *

Default integer value

- */ - _FinalStage default_(Optional default_); + _FinalStage default_(Optional default_); - _FinalStage default_(Integer default_); + _FinalStage default_(Double default_); /** *

Available integer options

*/ - _FinalStage options(Optional> options); + _FinalStage options(Optional> options); - _FinalStage options(List options); + _FinalStage options(List options); /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

@@ -384,9 +378,9 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); - private Optional> options = Optional.empty(); + private Optional> options = Optional.empty(); - private Optional default_ = Optional.empty(); + private Optional default_ = Optional.empty(); private Optional max = Optional.empty(); @@ -613,7 +607,7 @@ public _FinalStage label(Optional label) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage options(List options) { + public _FinalStage options(List options) { this.options = Optional.ofNullable(options); return this; } @@ -623,27 +617,20 @@ public _FinalStage options(List options) { */ @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) - public _FinalStage options(Optional> options) { + public _FinalStage options(Optional> options) { this.options = options; return this; } - /** - *

Default integer value

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

Default integer value

- */ @java.lang.Override @JsonSetter(value = "default", nulls = Nulls.SKIP) - public _FinalStage default_(Optional default_) { + public _FinalStage default_(Optional default_) { this.default_ = default_; 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 1dd3ce0..dc2000d 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArray.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArray.java @@ -26,9 +26,9 @@ public final class ConfigurablePropIntegerArray { private final Optional max; - private final Optional> default_; + private final Optional> default_; - private final Optional> options; + private final Optional> options; private final String name; @@ -55,8 +55,8 @@ public final class ConfigurablePropIntegerArray { private ConfigurablePropIntegerArray( Optional min, Optional max, - Optional> default_, - Optional> options, + Optional> default_, + Optional> options, String name, Optional label, Optional description, @@ -110,7 +110,7 @@ public Optional getMax() { * @return Default array of integers */ @JsonProperty("default") - public Optional> getDefault() { + public Optional> getDefault() { return default_; } @@ -118,7 +118,7 @@ public Optional> getDefault() { * @return Available options for the integer array */ @JsonProperty("options") - public Optional> getOptions() { + public Optional> getOptions() { return options; } @@ -287,16 +287,16 @@ public interface _FinalStage { /** *

Default array of integers

*/ - _FinalStage default_(Optional> default_); + _FinalStage default_(Optional> default_); - _FinalStage default_(List default_); + _FinalStage default_(List default_); /** *

Available options for the integer array

*/ - _FinalStage options(Optional> options); + _FinalStage options(Optional> options); - _FinalStage options(List options); + _FinalStage options(List options); /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

@@ -384,9 +384,9 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); - private Optional> options = Optional.empty(); + private Optional> options = Optional.empty(); - private Optional> default_ = Optional.empty(); + private Optional> default_ = Optional.empty(); private Optional max = Optional.empty(); @@ -613,7 +613,7 @@ public _FinalStage label(Optional label) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage options(List options) { + public _FinalStage options(List options) { this.options = Optional.ofNullable(options); return this; } @@ -623,7 +623,7 @@ public _FinalStage options(List options) { */ @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) - public _FinalStage options(Optional> options) { + public _FinalStage options(Optional> options) { this.options = options; return this; } @@ -633,7 +633,7 @@ public _FinalStage options(Optional> options) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage default_(List default_) { + public _FinalStage default_(List default_) { this.default_ = Optional.ofNullable(default_); return this; } @@ -643,7 +643,7 @@ public _FinalStage default_(List default_) { */ @java.lang.Override @JsonSetter(value = "default", nulls = Nulls.SKIP) - public _FinalStage default_(Optional> default_) { + public _FinalStage default_(Optional> default_) { this.default_ = default_; return this; } diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArrayOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArrayOptionsItem.java new file mode 100644 index 0000000..bcb3a30 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerArrayOptionsItem.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropIntegerArrayOptionsItem.Deserializer.class) +public final class ConfigurablePropIntegerArrayOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropIntegerArrayOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropIntegerArrayOptionsItem + && equalTo((ConfigurablePropIntegerArrayOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropIntegerArrayOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropIntegerArrayOptionsItem of(PropOption value) { + return new ConfigurablePropIntegerArrayOptionsItem(value, 0); + } + + public static ConfigurablePropIntegerArrayOptionsItem of(PropOptionNested value) { + return new ConfigurablePropIntegerArrayOptionsItem(value, 1); + } + + public static ConfigurablePropIntegerArrayOptionsItem of(Optional value) { + return new ConfigurablePropIntegerArrayOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropIntegerArrayOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropIntegerArrayOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerOptionsItem.java new file mode 100644 index 0000000..f33bbb2 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropIntegerOptionsItem.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropIntegerOptionsItem.Deserializer.class) +public final class ConfigurablePropIntegerOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropIntegerOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropIntegerOptionsItem + && equalTo((ConfigurablePropIntegerOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropIntegerOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropIntegerOptionsItem of(PropOption value) { + return new ConfigurablePropIntegerOptionsItem(value, 0); + } + + public static ConfigurablePropIntegerOptionsItem of(PropOptionNested value) { + return new ConfigurablePropIntegerOptionsItem(value, 1); + } + + public static ConfigurablePropIntegerOptionsItem of(Optional value) { + return new ConfigurablePropIntegerOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropIntegerOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropIntegerOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java b/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java index d6aa6f6..6174398 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropObject.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +22,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigurablePropObject.Builder.class) public final class ConfigurablePropObject { + private final Optional> default_; + + private final Optional> options; + private final String name; private final Optional label; @@ -44,6 +49,8 @@ public final class ConfigurablePropObject { private final Map additionalProperties; private ConfigurablePropObject( + Optional> default_, + Optional> options, String name, Optional label, Optional description, @@ -55,6 +62,8 @@ private ConfigurablePropObject( Optional reloadProps, Optional withLabel, Map additionalProperties) { + this.default_ = default_; + this.options = options; this.name = name; this.label = label; this.description = description; @@ -73,6 +82,16 @@ public String getType() { return "object"; } + @JsonProperty("default") + public Optional> getDefault() { + return default_; + } + + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + /** * @return When building configuredProps, make sure to use this field as the key when setting the prop value */ @@ -165,7 +184,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConfigurablePropObject other) { - return name.equals(other.name) + return default_.equals(other.default_) + && options.equals(other.options) + && name.equals(other.name) && label.equals(other.label) && description.equals(other.description) && optional.equals(other.optional) @@ -180,6 +201,8 @@ private boolean equalTo(ConfigurablePropObject other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.default_, + this.options, this.name, this.label, this.description, @@ -213,6 +236,14 @@ public interface NameStage { public interface _FinalStage { ConfigurablePropObject build(); + _FinalStage default_(Optional> default_); + + _FinalStage default_(Map default_); + + _FinalStage options(Optional> options); + + _FinalStage options(List options); + /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

*/ @@ -299,6 +330,10 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); + private Optional> options = Optional.empty(); + + private Optional> default_ = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -306,6 +341,8 @@ private Builder() {} @java.lang.Override public Builder from(ConfigurablePropObject other) { + default_(other.getDefault()); + options(other.getOptions()); name(other.getName()); label(other.getLabel()); description(other.getDescription()); @@ -511,9 +548,37 @@ public _FinalStage label(Optional label) { return this; } + @java.lang.Override + public _FinalStage options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + return this; + } + + @java.lang.Override + public _FinalStage default_(Map default_) { + this.default_ = Optional.ofNullable(default_); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default", nulls = Nulls.SKIP) + public _FinalStage default_(Optional> default_) { + this.default_ = default_; + return this; + } + @java.lang.Override public ConfigurablePropObject build() { return new ConfigurablePropObject( + default_, + options, name, label, description, diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropObjectOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropObjectOptionsItem.java new file mode 100644 index 0000000..90f9c20 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropObjectOptionsItem.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropObjectOptionsItem.Deserializer.class) +public final class ConfigurablePropObjectOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropObjectOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropObjectOptionsItem && equalTo((ConfigurablePropObjectOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropObjectOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropObjectOptionsItem of(PropOption value) { + return new ConfigurablePropObjectOptionsItem(value, 0); + } + + public static ConfigurablePropObjectOptionsItem of(PropOptionNested value) { + return new ConfigurablePropObjectOptionsItem(value, 1); + } + + public static ConfigurablePropObjectOptionsItem of(Optional value) { + return new ConfigurablePropObjectOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropObjectOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropObjectOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java b/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java index d0305aa..7a570e1 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropSql.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,7 +24,9 @@ public final class ConfigurablePropSql { private final Optional auth; - private final Optional default_; + private final Optional default_; + + private final Optional> options; private final String name; @@ -49,7 +52,8 @@ public final class ConfigurablePropSql { private ConfigurablePropSql( Optional auth, - Optional default_, + Optional default_, + Optional> options, String name, Optional label, Optional description, @@ -63,6 +67,7 @@ private ConfigurablePropSql( Map additionalProperties) { this.auth = auth; this.default_ = default_; + this.options = options; this.name = name; this.label = label; this.description = description; @@ -86,14 +91,16 @@ public Optional getAuth() { return auth; } - /** - * @return Default SQL query - */ @JsonProperty("default") - public Optional getDefault() { + public Optional getDefault() { return default_; } + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + /** * @return When building configuredProps, make sure to use this field as the key when setting the prop value */ @@ -188,6 +195,7 @@ public Map getAdditionalProperties() { private boolean equalTo(ConfigurablePropSql other) { return auth.equals(other.auth) && default_.equals(other.default_) + && options.equals(other.options) && name.equals(other.name) && label.equals(other.label) && description.equals(other.description) @@ -205,6 +213,7 @@ public int hashCode() { return Objects.hash( this.auth, this.default_, + this.options, this.name, this.label, this.description, @@ -242,12 +251,13 @@ public interface _FinalStage { _FinalStage auth(ConfigurablePropSqlAuth auth); - /** - *

Default SQL query

- */ - _FinalStage default_(Optional default_); + _FinalStage default_(Optional default_); + + _FinalStage default_(ConfiguredPropValueSql default_); + + _FinalStage options(Optional> options); - _FinalStage default_(String default_); + _FinalStage options(List options); /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

@@ -335,7 +345,9 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); - private Optional default_ = Optional.empty(); + private Optional> options = Optional.empty(); + + private Optional default_ = Optional.empty(); private Optional auth = Optional.empty(); @@ -348,6 +360,7 @@ private Builder() {} public Builder from(ConfigurablePropSql other) { auth(other.getAuth()); default_(other.getDefault()); + options(other.getOptions()); name(other.getName()); label(other.getLabel()); description(other.getDescription()); @@ -553,22 +566,28 @@ public _FinalStage label(Optional label) { return this; } - /** - *

Default SQL query

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage default_(String default_) { + public _FinalStage options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + return this; + } + + @java.lang.Override + public _FinalStage default_(ConfiguredPropValueSql default_) { this.default_ = Optional.ofNullable(default_); return this; } - /** - *

Default SQL query

- */ @java.lang.Override @JsonSetter(value = "default", nulls = Nulls.SKIP) - public _FinalStage default_(Optional default_) { + public _FinalStage default_(Optional default_) { this.default_ = default_; return this; } @@ -591,6 +610,7 @@ public ConfigurablePropSql build() { return new ConfigurablePropSql( auth, default_, + options, name, label, description, diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropSqlOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropSqlOptionsItem.java new file mode 100644 index 0000000..7bdc630 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropSqlOptionsItem.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropSqlOptionsItem.Deserializer.class) +public final class ConfigurablePropSqlOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropSqlOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropSqlOptionsItem && equalTo((ConfigurablePropSqlOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropSqlOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropSqlOptionsItem of(PropOption value) { + return new ConfigurablePropSqlOptionsItem(value, 0); + } + + public static ConfigurablePropSqlOptionsItem of(PropOptionNested value) { + return new ConfigurablePropSqlOptionsItem(value, 1); + } + + public static ConfigurablePropSqlOptionsItem of(Optional value) { + return new ConfigurablePropSqlOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropSqlOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropSqlOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropString.java b/src/main/java/com/pipedream/api/types/ConfigurablePropString.java index 1fe3aa0..d1ce2e7 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropString.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropString.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.pipedream.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +22,11 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigurablePropString.Builder.class) public final class ConfigurablePropString { + private final Optional secret; + private final Optional default_; - private final Optional secret; + private final Optional> options; private final String name; @@ -48,8 +51,9 @@ public final class ConfigurablePropString { private final Map additionalProperties; private ConfigurablePropString( - Optional default_, Optional secret, + Optional default_, + Optional> options, String name, Optional label, Optional description, @@ -61,8 +65,9 @@ private ConfigurablePropString( Optional reloadProps, Optional withLabel, Map additionalProperties) { - this.default_ = default_; this.secret = secret; + this.default_ = default_; + this.options = options; this.name = name; this.label = label; this.description = description; @@ -82,19 +87,21 @@ public String getType() { } /** - * @return The default value for this prop + * @return If true, this prop is a secret and should not be displayed in plain text. */ + @JsonProperty("secret") + public Optional getSecret() { + return secret; + } + @JsonProperty("default") public Optional getDefault() { return default_; } - /** - * @return If true, this prop is a secret and should not be displayed in plain text. - */ - @JsonProperty("secret") - public Optional getSecret() { - return secret; + @JsonProperty("options") + public Optional> getOptions() { + return options; } /** @@ -189,8 +196,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConfigurablePropString other) { - return default_.equals(other.default_) - && secret.equals(other.secret) + return secret.equals(other.secret) + && default_.equals(other.default_) + && options.equals(other.options) && name.equals(other.name) && label.equals(other.label) && description.equals(other.description) @@ -206,8 +214,9 @@ private boolean equalTo(ConfigurablePropString other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.default_, this.secret, + this.default_, + this.options, this.name, this.label, this.description, @@ -242,18 +251,19 @@ public interface _FinalStage { ConfigurablePropString build(); /** - *

The default value for this prop

+ *

If true, this prop is a secret and should not be displayed in plain text.

*/ + _FinalStage secret(Optional secret); + + _FinalStage secret(Boolean secret); + _FinalStage default_(Optional default_); _FinalStage default_(String default_); - /** - *

If true, this prop is a secret and should not be displayed in plain text.

- */ - _FinalStage secret(Optional secret); + _FinalStage options(Optional> options); - _FinalStage secret(Boolean secret); + _FinalStage options(List options); /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

@@ -341,10 +351,12 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); - private Optional secret = Optional.empty(); + private Optional> options = Optional.empty(); private Optional default_ = Optional.empty(); + private Optional secret = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -352,8 +364,9 @@ private Builder() {} @java.lang.Override public Builder from(ConfigurablePropString other) { - default_(other.getDefault()); secret(other.getSecret()); + default_(other.getDefault()); + options(other.getOptions()); name(other.getName()); label(other.getLabel()); description(other.getDescription()); @@ -559,39 +572,25 @@ public _FinalStage label(Optional label) { return this; } - /** - *

If true, this prop is a secret and should not be displayed in plain text.

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

If true, this prop is a secret and should not be displayed in plain text.

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

The default value for this prop

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

The default value for this prop

- */ @java.lang.Override @JsonSetter(value = "default", nulls = Nulls.SKIP) public _FinalStage default_(Optional default_) { @@ -599,11 +598,32 @@ public _FinalStage default_(Optional default_) { return this; } + /** + *

If true, this prop is a secret and should not be displayed in plain text.

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

If true, this prop is a secret and should not be displayed in plain text.

+ */ + @java.lang.Override + @JsonSetter(value = "secret", nulls = Nulls.SKIP) + public _FinalStage secret(Optional secret) { + this.secret = secret; + return this; + } + @java.lang.Override public ConfigurablePropString build() { return new ConfigurablePropString( - default_, secret, + default_, + options, name, label, description, diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java b/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java index 60d782c..af508a0 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropStringArray.java @@ -22,9 +22,11 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigurablePropStringArray.Builder.class) public final class ConfigurablePropStringArray { + private final Optional secret; + private final Optional> default_; - private final Optional secret; + private final Optional> options; private final String name; @@ -49,8 +51,9 @@ public final class ConfigurablePropStringArray { private final Map additionalProperties; private ConfigurablePropStringArray( - Optional> default_, Optional secret, + Optional> default_, + Optional> options, String name, Optional label, Optional description, @@ -62,8 +65,9 @@ private ConfigurablePropStringArray( Optional reloadProps, Optional withLabel, Map additionalProperties) { - this.default_ = default_; this.secret = secret; + this.default_ = default_; + this.options = options; this.name = name; this.label = label; this.description = description; @@ -82,6 +86,14 @@ public String getType() { return "string[]"; } + /** + * @return If true, this prop is a secret and should not be displayed in plain text. + */ + @JsonProperty("secret") + public Optional getSecret() { + return secret; + } + /** * @return The default value for this prop */ @@ -90,12 +102,9 @@ public Optional> getDefault() { return default_; } - /** - * @return If true, this prop is a secret and should not be displayed in plain text. - */ - @JsonProperty("secret") - public Optional getSecret() { - return secret; + @JsonProperty("options") + public Optional> getOptions() { + return options; } /** @@ -190,8 +199,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConfigurablePropStringArray other) { - return default_.equals(other.default_) - && secret.equals(other.secret) + return secret.equals(other.secret) + && default_.equals(other.default_) + && options.equals(other.options) && name.equals(other.name) && label.equals(other.label) && description.equals(other.description) @@ -207,8 +217,9 @@ private boolean equalTo(ConfigurablePropStringArray other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.default_, this.secret, + this.default_, + this.options, this.name, this.label, this.description, @@ -242,6 +253,13 @@ public interface NameStage { public interface _FinalStage { ConfigurablePropStringArray build(); + /** + *

If true, this prop is a secret and should not be displayed in plain text.

+ */ + _FinalStage secret(Optional secret); + + _FinalStage secret(Boolean secret); + /** *

The default value for this prop

*/ @@ -249,12 +267,9 @@ public interface _FinalStage { _FinalStage default_(List default_); - /** - *

If true, this prop is a secret and should not be displayed in plain text.

- */ - _FinalStage secret(Optional secret); + _FinalStage options(Optional> options); - _FinalStage secret(Boolean secret); + _FinalStage options(List options); /** *

Value to use as an input label. In cases where type is "app", should load the app via getApp, etc. and show app.name instead.

@@ -342,10 +357,12 @@ public static final class Builder implements NameStage, _FinalStage { private Optional label = Optional.empty(); - private Optional secret = Optional.empty(); + private Optional> options = Optional.empty(); private Optional> default_ = Optional.empty(); + private Optional secret = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -353,8 +370,9 @@ private Builder() {} @java.lang.Override public Builder from(ConfigurablePropStringArray other) { - default_(other.getDefault()); secret(other.getSecret()); + default_(other.getDefault()); + options(other.getOptions()); name(other.getName()); label(other.getLabel()); description(other.getDescription()); @@ -560,23 +578,16 @@ public _FinalStage label(Optional label) { return this; } - /** - *

If true, this prop is a secret and should not be displayed in plain text.

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

If true, this prop is a secret and should not be displayed in plain text.

- */ @java.lang.Override - @JsonSetter(value = "secret", nulls = Nulls.SKIP) - public _FinalStage secret(Optional secret) { - this.secret = secret; + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; return this; } @@ -600,11 +611,32 @@ public _FinalStage default_(Optional> default_) { return this; } + /** + *

If true, this prop is a secret and should not be displayed in plain text.

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

If true, this prop is a secret and should not be displayed in plain text.

+ */ + @java.lang.Override + @JsonSetter(value = "secret", nulls = Nulls.SKIP) + public _FinalStage secret(Optional secret) { + this.secret = secret; + return this; + } + @java.lang.Override public ConfigurablePropStringArray build() { return new ConfigurablePropStringArray( - default_, secret, + default_, + options, name, label, description, diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropStringArrayOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropStringArrayOptionsItem.java new file mode 100644 index 0000000..8a6865e --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropStringArrayOptionsItem.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropStringArrayOptionsItem.Deserializer.class) +public final class ConfigurablePropStringArrayOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropStringArrayOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropStringArrayOptionsItem + && equalTo((ConfigurablePropStringArrayOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropStringArrayOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropStringArrayOptionsItem of(PropOption value) { + return new ConfigurablePropStringArrayOptionsItem(value, 0); + } + + public static ConfigurablePropStringArrayOptionsItem of(PropOptionNested value) { + return new ConfigurablePropStringArrayOptionsItem(value, 1); + } + + public static ConfigurablePropStringArrayOptionsItem of(Optional value) { + return new ConfigurablePropStringArrayOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropStringArrayOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropStringArrayOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropStringOptionsItem.java b/src/main/java/com/pipedream/api/types/ConfigurablePropStringOptionsItem.java new file mode 100644 index 0000000..815c58e --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropStringOptionsItem.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.pipedream.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonDeserialize(using = ConfigurablePropStringOptionsItem.Deserializer.class) +public final class ConfigurablePropStringOptionsItem { + private final Object value; + + private final int type; + + private ConfigurablePropStringOptionsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((PropOption) this.value); + } else if (this.type == 1) { + return visitor.visit((PropOptionNested) this.value); + } else if (this.type == 2) { + return visitor.visit((Optional) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConfigurablePropStringOptionsItem && equalTo((ConfigurablePropStringOptionsItem) other); + } + + private boolean equalTo(ConfigurablePropStringOptionsItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static ConfigurablePropStringOptionsItem of(PropOption value) { + return new ConfigurablePropStringOptionsItem(value, 0); + } + + public static ConfigurablePropStringOptionsItem of(PropOptionNested value) { + return new ConfigurablePropStringOptionsItem(value, 1); + } + + public static ConfigurablePropStringOptionsItem of(Optional value) { + return new ConfigurablePropStringOptionsItem(value, 2); + } + + public interface Visitor { + T visit(PropOption value); + + T visit(PropOptionNested value); + + T visit(Optional value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ConfigurablePropStringOptionsItem.class); + } + + @java.lang.Override + public ConfigurablePropStringOptionsItem deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOption.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PropOptionNested.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ConfigurablePropType.java b/src/main/java/com/pipedream/api/types/ConfigurablePropType.java index ed58e25..ae5fd13 100644 --- a/src/main/java/com/pipedream/api/types/ConfigurablePropType.java +++ b/src/main/java/com/pipedream/api/types/ConfigurablePropType.java @@ -3,64 +3,301 @@ */ package com.pipedream.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ConfigurablePropType { - AIRTABLE_BASE_ID("$.airtable.baseId"), +public final class ConfigurablePropType { + public static final ConfigurablePropType AIRTABLE_VIEW_ID = + new ConfigurablePropType(Value.AIRTABLE_VIEW_ID, "$.airtable.viewId"); - AIRTABLE_FIELD_ID("$.airtable.fieldId"), + public static final ConfigurablePropType APP = new ConfigurablePropType(Value.APP, "app"); - AIRTABLE_TABLE_ID("$.airtable.tableId"), + public static final ConfigurablePropType AIRTABLE_BASE_ID = + new ConfigurablePropType(Value.AIRTABLE_BASE_ID, "$.airtable.baseId"); - AIRTABLE_VIEW_ID("$.airtable.viewId"), + public static final ConfigurablePropType AIRTABLE_TABLE_ID = + new ConfigurablePropType(Value.AIRTABLE_TABLE_ID, "$.airtable.tableId"); - DISCORD_CHANNEL("$.discord.channel"), + public static final ConfigurablePropType BOOLEAN = new ConfigurablePropType(Value.BOOLEAN, "boolean"); - DISCORD_CHANNEL_ARRAY("$.discord.channel[]"), + public static final ConfigurablePropType INTERFACE_TIMER = + new ConfigurablePropType(Value.INTERFACE_TIMER, "$.interface.timer"); - INTERFACE_APPHOOK("$.interface.apphook"), + public static final ConfigurablePropType ANY = new ConfigurablePropType(Value.ANY, "any"); - INTERFACE_HTTP("$.interface.http"), + public static final ConfigurablePropType SERVICE_DB = new ConfigurablePropType(Value.SERVICE_DB, "$.service.db"); - INTERFACE_TIMER("$.interface.timer"), + public static final ConfigurablePropType SQL = new ConfigurablePropType(Value.SQL, "sql"); - SERVICE_DB("$.service.db"), + public static final ConfigurablePropType AIRTABLE_FIELD_ID = + new ConfigurablePropType(Value.AIRTABLE_FIELD_ID, "$.airtable.fieldId"); - ALERT("alert"), + public static final ConfigurablePropType STRING_ARRAY = new ConfigurablePropType(Value.STRING_ARRAY, "string[]"); - ANY("any"), + public static final ConfigurablePropType DISCORD_CHANNEL_ARRAY = + new ConfigurablePropType(Value.DISCORD_CHANNEL_ARRAY, "$.discord.channel[]"); - APP("app"), + public static final ConfigurablePropType OBJECT = new ConfigurablePropType(Value.OBJECT, "object"); - BOOLEAN("boolean"), + public static final ConfigurablePropType INTERFACE_APPHOOK = + new ConfigurablePropType(Value.INTERFACE_APPHOOK, "$.interface.apphook"); - DATA_STORE("data_store"), + public static final ConfigurablePropType ALERT = new ConfigurablePropType(Value.ALERT, "alert"); - DIR("dir"), + public static final ConfigurablePropType STRING = new ConfigurablePropType(Value.STRING, "string"); - HTTP_REQUEST("http_request"), + public static final ConfigurablePropType INTEGER = new ConfigurablePropType(Value.INTEGER, "integer"); - INTEGER("integer"), + public static final ConfigurablePropType DISCORD_CHANNEL = + new ConfigurablePropType(Value.DISCORD_CHANNEL, "$.discord.channel"); - INTEGER_ARRAY("integer[]"), + public static final ConfigurablePropType INTEGER_ARRAY = new ConfigurablePropType(Value.INTEGER_ARRAY, "integer[]"); - OBJECT("object"), + public static final ConfigurablePropType DATA_STORE = new ConfigurablePropType(Value.DATA_STORE, "data_store"); - SQL("sql"), + public static final ConfigurablePropType HTTP_REQUEST = + new ConfigurablePropType(Value.HTTP_REQUEST, "http_request"); - STRING("string"), + public static final ConfigurablePropType DIR = new ConfigurablePropType(Value.DIR, "dir"); - STRING_ARRAY("string[]"); + public static final ConfigurablePropType INTERFACE_HTTP = + new ConfigurablePropType(Value.INTERFACE_HTTP, "$.interface.http"); - private final String value; + private final Value value; - ConfigurablePropType(String value) { + private final String string; + + ConfigurablePropType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ConfigurablePropType && this.string.equals(((ConfigurablePropType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case AIRTABLE_VIEW_ID: + return visitor.visitAirtableViewId(); + case APP: + return visitor.visitApp(); + case AIRTABLE_BASE_ID: + return visitor.visitAirtableBaseId(); + case AIRTABLE_TABLE_ID: + return visitor.visitAirtableTableId(); + case BOOLEAN: + return visitor.visitBoolean(); + case INTERFACE_TIMER: + return visitor.visitInterfaceTimer(); + case ANY: + return visitor.visitAny(); + case SERVICE_DB: + return visitor.visitServiceDb(); + case SQL: + return visitor.visitSql(); + case AIRTABLE_FIELD_ID: + return visitor.visitAirtableFieldId(); + case STRING_ARRAY: + return visitor.visitStringArray(); + case DISCORD_CHANNEL_ARRAY: + return visitor.visitDiscordChannelArray(); + case OBJECT: + return visitor.visitObject(); + case INTERFACE_APPHOOK: + return visitor.visitInterfaceApphook(); + case ALERT: + return visitor.visitAlert(); + case STRING: + return visitor.visitString(); + case INTEGER: + return visitor.visitInteger(); + case DISCORD_CHANNEL: + return visitor.visitDiscordChannel(); + case INTEGER_ARRAY: + return visitor.visitIntegerArray(); + case DATA_STORE: + return visitor.visitDataStore(); + case HTTP_REQUEST: + return visitor.visitHttpRequest(); + case DIR: + return visitor.visitDir(); + case INTERFACE_HTTP: + return visitor.visitInterfaceHttp(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ConfigurablePropType valueOf(String value) { + switch (value) { + case "$.airtable.viewId": + return AIRTABLE_VIEW_ID; + case "app": + return APP; + case "$.airtable.baseId": + return AIRTABLE_BASE_ID; + case "$.airtable.tableId": + return AIRTABLE_TABLE_ID; + case "boolean": + return BOOLEAN; + case "$.interface.timer": + return INTERFACE_TIMER; + case "any": + return ANY; + case "$.service.db": + return SERVICE_DB; + case "sql": + return SQL; + case "$.airtable.fieldId": + return AIRTABLE_FIELD_ID; + case "string[]": + return STRING_ARRAY; + case "$.discord.channel[]": + return DISCORD_CHANNEL_ARRAY; + case "object": + return OBJECT; + case "$.interface.apphook": + return INTERFACE_APPHOOK; + case "alert": + return ALERT; + case "string": + return STRING; + case "integer": + return INTEGER; + case "$.discord.channel": + return DISCORD_CHANNEL; + case "integer[]": + return INTEGER_ARRAY; + case "data_store": + return DATA_STORE; + case "http_request": + return HTTP_REQUEST; + case "dir": + return DIR; + case "$.interface.http": + return INTERFACE_HTTP; + default: + return new ConfigurablePropType(Value.UNKNOWN, value); + } + } + + public enum Value { + AIRTABLE_BASE_ID, + + AIRTABLE_FIELD_ID, + + AIRTABLE_TABLE_ID, + + AIRTABLE_VIEW_ID, + + DISCORD_CHANNEL, + + DISCORD_CHANNEL_ARRAY, + + INTERFACE_APPHOOK, + + INTERFACE_HTTP, + + INTERFACE_TIMER, + + SERVICE_DB, + + ALERT, + + ANY, + + APP, + + BOOLEAN, + + DATA_STORE, + + DIR, + + HTTP_REQUEST, + + INTEGER, + + INTEGER_ARRAY, + + OBJECT, + + SQL, + + STRING, + + STRING_ARRAY, + + UNKNOWN + } + + public interface Visitor { + T visitAirtableBaseId(); + + T visitAirtableFieldId(); + + T visitAirtableTableId(); + + T visitAirtableViewId(); + + T visitDiscordChannel(); + + T visitDiscordChannelArray(); + + T visitInterfaceApphook(); + + T visitInterfaceHttp(); + + T visitInterfaceTimer(); + + T visitServiceDb(); + + T visitAlert(); + + T visitAny(); + + T visitApp(); + + T visitBoolean(); + + T visitDataStore(); + + T visitDir(); + + T visitHttpRequest(); + + T visitInteger(); + + T visitIntegerArray(); + + T visitObject(); + + T visitSql(); + + T visitString(); + + T visitStringArray(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/types/ConfiguredPropValueSql.java b/src/main/java/com/pipedream/api/types/ConfiguredPropValueSql.java index 22ce442..1f1c3f8 100644 --- a/src/main/java/com/pipedream/api/types/ConfiguredPropValueSql.java +++ b/src/main/java/com/pipedream/api/types/ConfiguredPropValueSql.java @@ -234,7 +234,9 @@ public _FinalStage addParams(String params) { @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(List params) { this.params.clear(); - this.params.addAll(params); + if (params != null) { + this.params.addAll(params); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/DeployTriggerResponse.java b/src/main/java/com/pipedream/api/types/DeployTriggerResponse.java index 09aac9d..2115316 100644 --- a/src/main/java/com/pipedream/api/types/DeployTriggerResponse.java +++ b/src/main/java/com/pipedream/api/types/DeployTriggerResponse.java @@ -19,17 +19,17 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeployTriggerResponse.Builder.class) public final class DeployTriggerResponse { - private final DeployedComponent data; + private final Emitter data; private final Map additionalProperties; - private DeployTriggerResponse(DeployedComponent data, Map additionalProperties) { + private DeployTriggerResponse(Emitter data, Map additionalProperties) { this.data = data; this.additionalProperties = additionalProperties; } @JsonProperty("data") - public DeployedComponent getData() { + public Emitter getData() { return data; } @@ -63,7 +63,7 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull DeployedComponent data); + _FinalStage data(@NotNull Emitter data); Builder from(DeployTriggerResponse other); } @@ -74,7 +74,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private DeployedComponent data; + private Emitter data; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -89,7 +89,7 @@ public Builder from(DeployTriggerResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull DeployedComponent data) { + public _FinalStage data(@NotNull Emitter data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } diff --git a/src/main/java/com/pipedream/api/types/DeployedComponent.java b/src/main/java/com/pipedream/api/types/DeployedComponent.java index d5d704f..f019798 100644 --- a/src/main/java/com/pipedream/api/types/DeployedComponent.java +++ b/src/main/java/com/pipedream/api/types/DeployedComponent.java @@ -30,6 +30,8 @@ public final class DeployedComponent { private final String componentId; + private final Optional componentKey; + private final List configurableProps; private final Map configuredProps; @@ -52,6 +54,7 @@ private DeployedComponent( String id, String ownerId, String componentId, + Optional componentKey, List configurableProps, Map configuredProps, boolean active, @@ -64,6 +67,7 @@ private DeployedComponent( this.id = id; this.ownerId = ownerId; this.componentId = componentId; + this.componentKey = componentKey; this.configurableProps = configurableProps; this.configuredProps = configuredProps; this.active = active; @@ -99,6 +103,14 @@ public String getComponentId() { return componentId; } + /** + * @return The component key (name) that was deployed + */ + @JsonProperty("component_key") + public Optional getComponentKey() { + return componentKey; + } + /** * @return The configurable properties of the component */ @@ -152,6 +164,9 @@ public String getNameSlug() { return nameSlug; } + /** + * @return Callback observations for the deployed component + */ @JsonProperty("callback_observations") public Optional getCallbackObservations() { return callbackObservations; @@ -172,6 +187,7 @@ private boolean equalTo(DeployedComponent other) { return id.equals(other.id) && ownerId.equals(other.ownerId) && componentId.equals(other.componentId) + && componentKey.equals(other.componentKey) && configurableProps.equals(other.configurableProps) && configuredProps.equals(other.configuredProps) && active == other.active @@ -188,6 +204,7 @@ public int hashCode() { this.id, this.ownerId, this.componentId, + this.componentKey, this.configurableProps, this.configuredProps, this.active, @@ -268,6 +285,13 @@ public interface NameSlugStage { public interface _FinalStage { DeployedComponent build(); + /** + *

The component key (name) that was deployed

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

The configurable properties of the component

*/ @@ -283,6 +307,9 @@ public interface _FinalStage { _FinalStage configuredProps(String key, ConfiguredPropValue value); + /** + *

Callback observations for the deployed component

+ */ _FinalStage callbackObservations(Optional callbackObservations); _FinalStage callbackObservations(Object callbackObservations); @@ -321,6 +348,8 @@ public static final class Builder private List configurableProps = new ArrayList<>(); + private Optional componentKey = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -331,6 +360,7 @@ public Builder from(DeployedComponent other) { id(other.getId()); ownerId(other.getOwnerId()); componentId(other.getComponentId()); + componentKey(other.getComponentKey()); configurableProps(other.getConfigurableProps()); configuredProps(other.getConfiguredProps()); active(other.getActive()); @@ -438,12 +468,19 @@ public _FinalStage nameSlug(@NotNull String nameSlug) { return this; } + /** + *

Callback observations for the deployed component

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

Callback observations for the deployed component

+ */ @java.lang.Override @JsonSetter(value = "callback_observations", nulls = Nulls.SKIP) public _FinalStage callbackObservations(Optional callbackObservations) { @@ -469,7 +506,9 @@ public _FinalStage putAllConfiguredProps(Map config @JsonSetter(value = "configured_props", nulls = Nulls.SKIP) public _FinalStage configuredProps(Map configuredProps) { this.configuredProps.clear(); - this.configuredProps.putAll(configuredProps); + if (configuredProps != null) { + this.configuredProps.putAll(configuredProps); + } return this; } @@ -502,7 +541,29 @@ public _FinalStage addConfigurableProps(ConfigurableProp configurableProps) { @JsonSetter(value = "configurable_props", nulls = Nulls.SKIP) public _FinalStage configurableProps(List configurableProps) { this.configurableProps.clear(); - this.configurableProps.addAll(configurableProps); + if (configurableProps != null) { + this.configurableProps.addAll(configurableProps); + } + return this; + } + + /** + *

The component key (name) that was deployed

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

The component key (name) that was deployed

+ */ + @java.lang.Override + @JsonSetter(value = "component_key", nulls = Nulls.SKIP) + public _FinalStage componentKey(Optional componentKey) { + this.componentKey = componentKey; return this; } @@ -512,6 +573,7 @@ public DeployedComponent build() { id, ownerId, componentId, + componentKey, configurableProps, configuredProps, active, diff --git a/src/main/java/com/pipedream/api/types/EmittedEvent.java b/src/main/java/com/pipedream/api/types/EmittedEvent.java index d5f6b1d..2a38828 100644 --- a/src/main/java/com/pipedream/api/types/EmittedEvent.java +++ b/src/main/java/com/pipedream/api/types/EmittedEvent.java @@ -225,7 +225,9 @@ public _FinalStage putAllE(Map e) { @JsonSetter(value = "e", nulls = Nulls.SKIP) public _FinalStage e(Map e) { this.e.clear(); - this.e.putAll(e); + if (e != null) { + this.e.putAll(e); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/Emitter.java b/src/main/java/com/pipedream/api/types/Emitter.java new file mode 100644 index 0000000..830adbd --- /dev/null +++ b/src/main/java/com/pipedream/api/types/Emitter.java @@ -0,0 +1,263 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class Emitter { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private Emitter(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static Emitter deployedComponent(DeployedComponent value) { + return new Emitter(new DeployedComponentValue(value)); + } + + public static Emitter httpInterface(HttpInterface value) { + return new Emitter(new HttpInterfaceValue(value)); + } + + public static Emitter timerInterface(TimerInterface value) { + return new Emitter(new TimerInterfaceValue(value)); + } + + public boolean isDeployedComponent() { + return value instanceof DeployedComponentValue; + } + + public boolean isHttpInterface() { + return value instanceof HttpInterfaceValue; + } + + public boolean isTimerInterface() { + return value instanceof TimerInterfaceValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getDeployedComponent() { + if (isDeployedComponent()) { + return Optional.of(((DeployedComponentValue) value).value); + } + return Optional.empty(); + } + + public Optional getHttpInterface() { + if (isHttpInterface()) { + return Optional.of(((HttpInterfaceValue) value).value); + } + return Optional.empty(); + } + + public Optional getTimerInterface() { + if (isTimerInterface()) { + return Optional.of(((TimerInterfaceValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitDeployedComponent(DeployedComponent deployedComponent); + + T visitHttpInterface(HttpInterface httpInterface); + + T visitTimerInterface(TimerInterface timerInterface); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(DeployedComponentValue.class), + @JsonSubTypes.Type(HttpInterfaceValue.class), + @JsonSubTypes.Type(TimerInterfaceValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("DeployedComponent") + @JsonIgnoreProperties("type") + private static final class DeployedComponentValue implements Value { + @JsonUnwrapped + private DeployedComponent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private DeployedComponentValue() {} + + private DeployedComponentValue(DeployedComponent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitDeployedComponent(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeployedComponentValue && equalTo((DeployedComponentValue) other); + } + + private boolean equalTo(DeployedComponentValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "Emitter{" + "value: " + value + "}"; + } + } + + @JsonTypeName("HttpInterface") + @JsonIgnoreProperties("type") + private static final class HttpInterfaceValue implements Value { + @JsonUnwrapped + private HttpInterface value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private HttpInterfaceValue() {} + + private HttpInterfaceValue(HttpInterface value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitHttpInterface(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HttpInterfaceValue && equalTo((HttpInterfaceValue) other); + } + + private boolean equalTo(HttpInterfaceValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "Emitter{" + "value: " + value + "}"; + } + } + + @JsonTypeName("TimerInterface") + @JsonIgnoreProperties("type") + private static final class TimerInterfaceValue implements Value { + @JsonUnwrapped + private TimerInterface value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private TimerInterfaceValue() {} + + private TimerInterfaceValue(TimerInterface value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitTimerInterface(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TimerInterfaceValue && equalTo((TimerInterfaceValue) other); + } + + private boolean equalTo(TimerInterfaceValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "Emitter{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "Emitter{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/pipedream/api/types/EmitterType.java b/src/main/java/com/pipedream/api/types/EmitterType.java new file mode 100644 index 0000000..ff4836f --- /dev/null +++ b/src/main/java/com/pipedream/api/types/EmitterType.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class EmitterType { + public static final EmitterType EMAIL = new EmitterType(Value.EMAIL, "email"); + + public static final EmitterType SOURCE = new EmitterType(Value.SOURCE, "source"); + + public static final EmitterType HTTP = new EmitterType(Value.HTTP, "http"); + + public static final EmitterType TIMER = new EmitterType(Value.TIMER, "timer"); + + private final Value value; + + private final String string; + + EmitterType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof EmitterType && this.string.equals(((EmitterType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EMAIL: + return visitor.visitEmail(); + case SOURCE: + return visitor.visitSource(); + case HTTP: + return visitor.visitHttp(); + case TIMER: + return visitor.visitTimer(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static EmitterType valueOf(String value) { + switch (value) { + case "email": + return EMAIL; + case "source": + return SOURCE; + case "http": + return HTTP; + case "timer": + return TIMER; + default: + return new EmitterType(Value.UNKNOWN, value); + } + } + + public enum Value { + EMAIL, + + HTTP, + + SOURCE, + + TIMER, + + UNKNOWN + } + + public interface Visitor { + T visitEmail(); + + T visitHttp(); + + T visitSource(); + + T visitTimer(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/pipedream/api/types/GetAccountsResponse.java b/src/main/java/com/pipedream/api/types/GetAccountsResponse.java index b39f48b..db86bc8 100644 --- a/src/main/java/com/pipedream/api/types/GetAccountsResponse.java +++ b/src/main/java/com/pipedream/api/types/GetAccountsResponse.java @@ -132,7 +132,9 @@ public _FinalStage addData(Account data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/GetAppsResponse.java b/src/main/java/com/pipedream/api/types/GetAppsResponse.java index 3317771..a7e58b7 100644 --- a/src/main/java/com/pipedream/api/types/GetAppsResponse.java +++ b/src/main/java/com/pipedream/api/types/GetAppsResponse.java @@ -132,7 +132,9 @@ public _FinalStage addData(App data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/GetComponentsResponse.java b/src/main/java/com/pipedream/api/types/GetComponentsResponse.java index a1b2135..d3fd762 100644 --- a/src/main/java/com/pipedream/api/types/GetComponentsResponse.java +++ b/src/main/java/com/pipedream/api/types/GetComponentsResponse.java @@ -132,7 +132,9 @@ public _FinalStage addData(Component data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/GetTriggerEventsResponse.java b/src/main/java/com/pipedream/api/types/GetTriggerEventsResponse.java index 07cdbd2..3ef8114 100644 --- a/src/main/java/com/pipedream/api/types/GetTriggerEventsResponse.java +++ b/src/main/java/com/pipedream/api/types/GetTriggerEventsResponse.java @@ -81,7 +81,9 @@ public Builder from(GetTriggerEventsResponse other) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public Builder data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/GetTriggerResponse.java b/src/main/java/com/pipedream/api/types/GetTriggerResponse.java index 697147e..7629b07 100644 --- a/src/main/java/com/pipedream/api/types/GetTriggerResponse.java +++ b/src/main/java/com/pipedream/api/types/GetTriggerResponse.java @@ -19,17 +19,17 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetTriggerResponse.Builder.class) public final class GetTriggerResponse { - private final DeployedComponent data; + private final Emitter data; private final Map additionalProperties; - private GetTriggerResponse(DeployedComponent data, Map additionalProperties) { + private GetTriggerResponse(Emitter data, Map additionalProperties) { this.data = data; this.additionalProperties = additionalProperties; } @JsonProperty("data") - public DeployedComponent getData() { + public Emitter getData() { return data; } @@ -63,7 +63,7 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull DeployedComponent data); + _FinalStage data(@NotNull Emitter data); Builder from(GetTriggerResponse other); } @@ -74,7 +74,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private DeployedComponent data; + private Emitter data; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -89,7 +89,7 @@ public Builder from(GetTriggerResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull DeployedComponent data) { + public _FinalStage data(@NotNull Emitter data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } diff --git a/src/main/java/com/pipedream/api/types/GetTriggerWebhooksResponse.java b/src/main/java/com/pipedream/api/types/GetTriggerWebhooksResponse.java index d61226b..f071104 100644 --- a/src/main/java/com/pipedream/api/types/GetTriggerWebhooksResponse.java +++ b/src/main/java/com/pipedream/api/types/GetTriggerWebhooksResponse.java @@ -81,7 +81,9 @@ public Builder from(GetTriggerWebhooksResponse other) { @JsonSetter(value = "webhook_urls", nulls = Nulls.SKIP) public Builder webhookUrls(List webhookUrls) { this.webhookUrls.clear(); - this.webhookUrls.addAll(webhookUrls); + if (webhookUrls != null) { + this.webhookUrls.addAll(webhookUrls); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/GetTriggerWorkflowsResponse.java b/src/main/java/com/pipedream/api/types/GetTriggerWorkflowsResponse.java index 9476f62..d88e56a 100644 --- a/src/main/java/com/pipedream/api/types/GetTriggerWorkflowsResponse.java +++ b/src/main/java/com/pipedream/api/types/GetTriggerWorkflowsResponse.java @@ -81,7 +81,9 @@ public Builder from(GetTriggerWorkflowsResponse other) { @JsonSetter(value = "workflow_ids", nulls = Nulls.SKIP) public Builder workflowIds(List workflowIds) { this.workflowIds.clear(); - this.workflowIds.addAll(workflowIds); + if (workflowIds != null) { + this.workflowIds.addAll(workflowIds); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/GetTriggersResponse.java b/src/main/java/com/pipedream/api/types/GetTriggersResponse.java index 30a2897..89c9a14 100644 --- a/src/main/java/com/pipedream/api/types/GetTriggersResponse.java +++ b/src/main/java/com/pipedream/api/types/GetTriggersResponse.java @@ -22,21 +22,20 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetTriggersResponse.Builder.class) public final class GetTriggersResponse { - private final List data; + private final List data; private final PageInfo pageInfo; private final Map additionalProperties; - private GetTriggersResponse( - List data, PageInfo pageInfo, Map additionalProperties) { + private GetTriggersResponse(List data, PageInfo pageInfo, Map additionalProperties) { this.data = data; this.pageInfo = pageInfo; this.additionalProperties = additionalProperties; } @JsonProperty("data") - public List getData() { + public List getData() { return data; } @@ -83,18 +82,18 @@ public interface PageInfoStage { public interface _FinalStage { GetTriggersResponse build(); - _FinalStage data(List data); + _FinalStage data(List data); - _FinalStage addData(DeployedComponent data); + _FinalStage addData(Emitter data); - _FinalStage addAllData(List data); + _FinalStage addAllData(List data); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements PageInfoStage, _FinalStage { private PageInfo pageInfo; - private List data = new ArrayList<>(); + private List data = new ArrayList<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -116,7 +115,7 @@ public _FinalStage pageInfo(@NotNull PageInfo pageInfo) { } @java.lang.Override - public _FinalStage addAllData(List data) { + public _FinalStage addAllData(List data) { if (data != null) { this.data.addAll(data); } @@ -124,16 +123,18 @@ public _FinalStage addAllData(List data) { } @java.lang.Override - public _FinalStage addData(DeployedComponent data) { + public _FinalStage addData(Emitter data) { this.data.add(data); return this; } @java.lang.Override @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(List data) { + public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/HTTPAuthType.java b/src/main/java/com/pipedream/api/types/HTTPAuthType.java deleted file mode 100644 index d4e4d15..0000000 --- a/src/main/java/com/pipedream/api/types/HTTPAuthType.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This file was manually created to add workflow invocation support. - */ -package com.pipedream.api.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Authentication types for workflow invocation - */ -public enum HTTPAuthType { - NONE("none"), - STATIC_BEARER("static_bearer_token"), - OAUTH("oauth"); - - private final String value; - - HTTPAuthType(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @JsonCreator - public static HTTPAuthType fromValue(String value) { - for (HTTPAuthType type : HTTPAuthType.values()) { - if (type.value.equals(value)) { - return type; - } - } - throw new IllegalArgumentException("Unknown HTTPAuthType: " + value); - } - - @Override - public String toString() { - return value; - } -} diff --git a/src/main/java/com/pipedream/api/types/HttpInterface.java b/src/main/java/com/pipedream/api/types/HttpInterface.java new file mode 100644 index 0000000..d01b3b9 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/HttpInterface.java @@ -0,0 +1,264 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.pipedream.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = HttpInterface.Builder.class) +public final class HttpInterface { + private final String id; + + private final String key; + + private final String endpointUrl; + + private final boolean customResponse; + + private final int createdAt; + + private final int updatedAt; + + private final Map additionalProperties; + + private HttpInterface( + String id, + String key, + String endpointUrl, + boolean customResponse, + int createdAt, + int updatedAt, + Map additionalProperties) { + this.id = id; + this.key = key; + this.endpointUrl = endpointUrl; + this.customResponse = customResponse; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique ID of the HTTP interface + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("endpoint_url") + public String getEndpointUrl() { + return endpointUrl; + } + + @JsonProperty("custom_response") + public boolean getCustomResponse() { + return customResponse; + } + + /** + * @return The timestamp when the HTTP interface was created (epoch milliseconds) + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The timestamp when the HTTP interface was last updated (epoch milliseconds) + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HttpInterface && equalTo((HttpInterface) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HttpInterface other) { + return id.equals(other.id) + && key.equals(other.key) + && endpointUrl.equals(other.endpointUrl) + && customResponse == other.customResponse + && createdAt == other.createdAt + && updatedAt == other.updatedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.key, this.endpointUrl, this.customResponse, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + *

The unique ID of the HTTP interface

+ */ + KeyStage id(@NotNull String id); + + Builder from(HttpInterface other); + } + + public interface KeyStage { + EndpointUrlStage key(@NotNull String key); + } + + public interface EndpointUrlStage { + CustomResponseStage endpointUrl(@NotNull String endpointUrl); + } + + public interface CustomResponseStage { + CreatedAtStage customResponse(boolean customResponse); + } + + public interface CreatedAtStage { + /** + *

The timestamp when the HTTP interface was created (epoch milliseconds)

+ */ + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + /** + *

The timestamp when the HTTP interface was last updated (epoch milliseconds)

+ */ + _FinalStage updatedAt(int updatedAt); + } + + public interface _FinalStage { + HttpInterface build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + KeyStage, + EndpointUrlStage, + CustomResponseStage, + CreatedAtStage, + UpdatedAtStage, + _FinalStage { + private String id; + + private String key; + + private String endpointUrl; + + private boolean customResponse; + + private int createdAt; + + private int updatedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(HttpInterface other) { + id(other.getId()); + key(other.getKey()); + endpointUrl(other.getEndpointUrl()); + customResponse(other.getCustomResponse()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

The unique ID of the HTTP interface

+ *

The unique ID of the HTTP interface

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public KeyStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("key") + public EndpointUrlStage key(@NotNull String key) { + this.key = Objects.requireNonNull(key, "key must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("endpoint_url") + public CustomResponseStage endpointUrl(@NotNull String endpointUrl) { + this.endpointUrl = Objects.requireNonNull(endpointUrl, "endpointUrl must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("custom_response") + public CreatedAtStage customResponse(boolean customResponse) { + this.customResponse = customResponse; + return this; + } + + /** + *

The timestamp when the HTTP interface was created (epoch milliseconds)

+ *

The timestamp when the HTTP interface was created (epoch milliseconds)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

The timestamp when the HTTP interface was last updated (epoch milliseconds)

+ *

The timestamp when the HTTP interface was last updated (epoch milliseconds)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public HttpInterface build() { + return new HttpInterface(id, key, endpointUrl, customResponse, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ListAccountsResponse.java b/src/main/java/com/pipedream/api/types/ListAccountsResponse.java index 6b65425..ba57e76 100644 --- a/src/main/java/com/pipedream/api/types/ListAccountsResponse.java +++ b/src/main/java/com/pipedream/api/types/ListAccountsResponse.java @@ -132,7 +132,9 @@ public _FinalStage addData(Account data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/ListAppsResponse.java b/src/main/java/com/pipedream/api/types/ListAppsResponse.java index 77b5dd0..52caad3 100644 --- a/src/main/java/com/pipedream/api/types/ListAppsResponse.java +++ b/src/main/java/com/pipedream/api/types/ListAppsResponse.java @@ -132,7 +132,9 @@ public _FinalStage addData(App data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/ProjectEnvironment.java b/src/main/java/com/pipedream/api/types/ProjectEnvironment.java index aceb02c..421f0d3 100644 --- a/src/main/java/com/pipedream/api/types/ProjectEnvironment.java +++ b/src/main/java/com/pipedream/api/types/ProjectEnvironment.java @@ -3,22 +3,81 @@ */ package com.pipedream.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ProjectEnvironment { - DEVELOPMENT("development"), +public final class ProjectEnvironment { + public static final ProjectEnvironment DEVELOPMENT = new ProjectEnvironment(Value.DEVELOPMENT, "development"); - PRODUCTION("production"); + public static final ProjectEnvironment PRODUCTION = new ProjectEnvironment(Value.PRODUCTION, "production"); - private final String value; + private final Value value; - ProjectEnvironment(String value) { + private final String string; + + ProjectEnvironment(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ProjectEnvironment && this.string.equals(((ProjectEnvironment) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEVELOPMENT: + return visitor.visitDevelopment(); + case PRODUCTION: + return visitor.visitProduction(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ProjectEnvironment valueOf(String value) { + switch (value) { + case "development": + return DEVELOPMENT; + case "production": + return PRODUCTION; + default: + return new ProjectEnvironment(Value.UNKNOWN, value); + } + } + + public enum Value { + DEVELOPMENT, + + PRODUCTION, + + UNKNOWN + } + + public interface Visitor { + T visitDevelopment(); + + T visitProduction(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/pipedream/api/types/ProjectInfoResponse.java b/src/main/java/com/pipedream/api/types/ProjectInfoResponse.java index d0d36c5..8cb68d8 100644 --- a/src/main/java/com/pipedream/api/types/ProjectInfoResponse.java +++ b/src/main/java/com/pipedream/api/types/ProjectInfoResponse.java @@ -81,7 +81,9 @@ public Builder from(ProjectInfoResponse other) { @JsonSetter(value = "apps", nulls = Nulls.SKIP) public Builder apps(List apps) { this.apps.clear(); - this.apps.addAll(apps); + if (apps != null) { + this.apps.addAll(apps); + } return this; } diff --git a/src/main/java/com/pipedream/api/types/RunActionOptsStashId.java b/src/main/java/com/pipedream/api/types/RunActionOptsStashId.java index 8a85ab9..7f8622d 100644 --- a/src/main/java/com/pipedream/api/types/RunActionOptsStashId.java +++ b/src/main/java/com/pipedream/api/types/RunActionOptsStashId.java @@ -36,7 +36,7 @@ public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((Optional) this.value); } else if (this.type == 1) { - return visitor.visit((String) this.value); + return visitor.visit2((String) this.value); } else if (this.type == 2) { return visitor.visit((boolean) this.value); } @@ -73,7 +73,7 @@ public static RunActionOptsStashId of(Optional value) { *
  • "NEW"
  • * */ - public static RunActionOptsStashId of(String value) { + public static RunActionOptsStashId of2(String value) { return new RunActionOptsStashId(value, 1); } @@ -90,7 +90,7 @@ public interface Visitor { *
  • "NEW"
  • * */ - T visit(String value); + T visit2(String value); T visit(boolean value); } @@ -108,7 +108,7 @@ public RunActionOptsStashId deserialize(JsonParser p, DeserializationContext con } catch (RuntimeException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + return of2(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (RuntimeException e) { } if (value instanceof Boolean) { diff --git a/src/main/java/com/pipedream/api/types/RunActionResponse.java b/src/main/java/com/pipedream/api/types/RunActionResponse.java index 416bdbc..5c68e55 100644 --- a/src/main/java/com/pipedream/api/types/RunActionResponse.java +++ b/src/main/java/com/pipedream/api/types/RunActionResponse.java @@ -43,16 +43,25 @@ private RunActionResponse( this.additionalProperties = additionalProperties; } + /** + * @return The key-value pairs resulting from calls to $.export + */ @JsonProperty("exports") public Optional getExports() { return exports; } + /** + * @return Any logs produced during the execution of the action + */ @JsonProperty("os") public Optional getOs() { return os; } + /** + * @return The value returned by the action + */ @JsonProperty("ret") public Optional getRet() { return ret; @@ -118,6 +127,9 @@ public Builder from(RunActionResponse other) { return this; } + /** + *

    The key-value pairs resulting from calls to $.export

    + */ @JsonSetter(value = "exports", nulls = Nulls.SKIP) public Builder exports(Optional exports) { this.exports = exports; @@ -129,6 +141,9 @@ public Builder exports(Object exports) { return this; } + /** + *

    Any logs produced during the execution of the action

    + */ @JsonSetter(value = "os", nulls = Nulls.SKIP) public Builder os(Optional os) { this.os = os; @@ -140,6 +155,9 @@ public Builder os(Object os) { return this; } + /** + *

    The value returned by the action

    + */ @JsonSetter(value = "ret", nulls = Nulls.SKIP) public Builder ret(Optional ret) { this.ret = ret; diff --git a/src/main/java/com/pipedream/api/types/TimerInterface.java b/src/main/java/com/pipedream/api/types/TimerInterface.java new file mode 100644 index 0000000..de445d8 --- /dev/null +++ b/src/main/java/com/pipedream/api/types/TimerInterface.java @@ -0,0 +1,304 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.pipedream.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TimerInterface.Builder.class) +public final class TimerInterface { + private final String id; + + private final Optional intervalSeconds; + + private final Optional cron; + + private final String timezone; + + private final int scheduleChangedAt; + + private final int createdAt; + + private final int updatedAt; + + private final Map additionalProperties; + + private TimerInterface( + String id, + Optional intervalSeconds, + Optional cron, + String timezone, + int scheduleChangedAt, + int createdAt, + int updatedAt, + Map additionalProperties) { + this.id = id; + this.intervalSeconds = intervalSeconds; + this.cron = cron; + this.timezone = timezone; + this.scheduleChangedAt = scheduleChangedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique ID of the timer interface + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("interval_seconds") + public Optional getIntervalSeconds() { + return intervalSeconds; + } + + @JsonProperty("cron") + public Optional getCron() { + return cron; + } + + @JsonProperty("timezone") + public String getTimezone() { + return timezone; + } + + @JsonProperty("schedule_changed_at") + public int getScheduleChangedAt() { + return scheduleChangedAt; + } + + /** + * @return The timestamp when the timer interface was created (epoch milliseconds) + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The timestamp when the timer interface was last updated (epoch milliseconds) + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TimerInterface && equalTo((TimerInterface) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TimerInterface other) { + return id.equals(other.id) + && intervalSeconds.equals(other.intervalSeconds) + && cron.equals(other.cron) + && timezone.equals(other.timezone) + && scheduleChangedAt == other.scheduleChangedAt + && createdAt == other.createdAt + && updatedAt == other.updatedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.intervalSeconds, + this.cron, + this.timezone, + this.scheduleChangedAt, + this.createdAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + *

    The unique ID of the timer interface

    + */ + TimezoneStage id(@NotNull String id); + + Builder from(TimerInterface other); + } + + public interface TimezoneStage { + ScheduleChangedAtStage timezone(@NotNull String timezone); + } + + public interface ScheduleChangedAtStage { + CreatedAtStage scheduleChangedAt(int scheduleChangedAt); + } + + public interface CreatedAtStage { + /** + *

    The timestamp when the timer interface was created (epoch milliseconds)

    + */ + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + /** + *

    The timestamp when the timer interface was last updated (epoch milliseconds)

    + */ + _FinalStage updatedAt(int updatedAt); + } + + public interface _FinalStage { + TimerInterface build(); + + _FinalStage intervalSeconds(Optional intervalSeconds); + + _FinalStage intervalSeconds(Double intervalSeconds); + + _FinalStage cron(Optional cron); + + _FinalStage cron(String cron); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, TimezoneStage, ScheduleChangedAtStage, CreatedAtStage, UpdatedAtStage, _FinalStage { + private String id; + + private String timezone; + + private int scheduleChangedAt; + + private int createdAt; + + private int updatedAt; + + private Optional cron = Optional.empty(); + + private Optional intervalSeconds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TimerInterface other) { + id(other.getId()); + intervalSeconds(other.getIntervalSeconds()); + cron(other.getCron()); + timezone(other.getTimezone()); + scheduleChangedAt(other.getScheduleChangedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

    The unique ID of the timer interface

    + *

    The unique ID of the timer interface

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public TimezoneStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("timezone") + public ScheduleChangedAtStage timezone(@NotNull String timezone) { + this.timezone = Objects.requireNonNull(timezone, "timezone must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("schedule_changed_at") + public CreatedAtStage scheduleChangedAt(int scheduleChangedAt) { + this.scheduleChangedAt = scheduleChangedAt; + return this; + } + + /** + *

    The timestamp when the timer interface was created (epoch milliseconds)

    + *

    The timestamp when the timer interface was created (epoch milliseconds)

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

    The timestamp when the timer interface was last updated (epoch milliseconds)

    + *

    The timestamp when the timer interface was last updated (epoch milliseconds)

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public _FinalStage cron(String cron) { + this.cron = Optional.ofNullable(cron); + return this; + } + + @java.lang.Override + @JsonSetter(value = "cron", nulls = Nulls.SKIP) + public _FinalStage cron(Optional cron) { + this.cron = cron; + return this; + } + + @java.lang.Override + public _FinalStage intervalSeconds(Double intervalSeconds) { + this.intervalSeconds = Optional.ofNullable(intervalSeconds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "interval_seconds", nulls = Nulls.SKIP) + public _FinalStage intervalSeconds(Optional intervalSeconds) { + this.intervalSeconds = intervalSeconds; + return this; + } + + @java.lang.Override + public TimerInterface build() { + return new TimerInterface( + id, intervalSeconds, cron, timezone, scheduleChangedAt, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/pipedream/api/types/ToolAnnotations.java b/src/main/java/com/pipedream/api/types/ToolAnnotations.java new file mode 100644 index 0000000..ebbc4ec --- /dev/null +++ b/src/main/java/com/pipedream/api/types/ToolAnnotations.java @@ -0,0 +1,225 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.pipedream.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.pipedream.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ToolAnnotations.Builder.class) +public final class ToolAnnotations { + private final Optional destructiveHint; + + private final Optional idempotentHint; + + private final Optional openWorldHint; + + private final Optional readOnlyHint; + + private final Optional title; + + private final Map additionalProperties; + + private ToolAnnotations( + Optional destructiveHint, + Optional idempotentHint, + Optional openWorldHint, + Optional readOnlyHint, + Optional title, + Map additionalProperties) { + this.destructiveHint = destructiveHint; + this.idempotentHint = idempotentHint; + this.openWorldHint = openWorldHint; + this.readOnlyHint = readOnlyHint; + this.title = title; + this.additionalProperties = additionalProperties; + } + + /** + * @return If true, the component may perform destructive updates to its environment. If false, the component performs only additive updates. + */ + @JsonProperty("destructiveHint") + public Optional getDestructiveHint() { + return destructiveHint; + } + + /** + * @return If true, calling the component repeatedly with the same arguments will have no additional effect on the its environment. + */ + @JsonProperty("idempotentHint") + public Optional getIdempotentHint() { + return idempotentHint; + } + + /** + * @return If true, this component may interact with an “open world” of external entities. If false, the component's domain of interaction is closed. For example, the world of a web search component is open, whereas that of a memory component is not. + */ + @JsonProperty("openWorldHint") + public Optional getOpenWorldHint() { + return openWorldHint; + } + + /** + * @return If true, the component does not modify its environment. + */ + @JsonProperty("readOnlyHint") + public Optional getReadOnlyHint() { + return readOnlyHint; + } + + /** + * @return A human-readable title for the component. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ToolAnnotations && equalTo((ToolAnnotations) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ToolAnnotations other) { + return destructiveHint.equals(other.destructiveHint) + && idempotentHint.equals(other.idempotentHint) + && openWorldHint.equals(other.openWorldHint) + && readOnlyHint.equals(other.readOnlyHint) + && title.equals(other.title); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.destructiveHint, this.idempotentHint, this.openWorldHint, this.readOnlyHint, this.title); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional destructiveHint = Optional.empty(); + + private Optional idempotentHint = Optional.empty(); + + private Optional openWorldHint = Optional.empty(); + + private Optional readOnlyHint = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ToolAnnotations other) { + destructiveHint(other.getDestructiveHint()); + idempotentHint(other.getIdempotentHint()); + openWorldHint(other.getOpenWorldHint()); + readOnlyHint(other.getReadOnlyHint()); + title(other.getTitle()); + return this; + } + + /** + *

    If true, the component may perform destructive updates to its environment. If false, the component performs only additive updates.

    + */ + @JsonSetter(value = "destructiveHint", nulls = Nulls.SKIP) + public Builder destructiveHint(Optional destructiveHint) { + this.destructiveHint = destructiveHint; + return this; + } + + public Builder destructiveHint(Boolean destructiveHint) { + this.destructiveHint = Optional.ofNullable(destructiveHint); + return this; + } + + /** + *

    If true, calling the component repeatedly with the same arguments will have no additional effect on the its environment.

    + */ + @JsonSetter(value = "idempotentHint", nulls = Nulls.SKIP) + public Builder idempotentHint(Optional idempotentHint) { + this.idempotentHint = idempotentHint; + return this; + } + + public Builder idempotentHint(Boolean idempotentHint) { + this.idempotentHint = Optional.ofNullable(idempotentHint); + return this; + } + + /** + *

    If true, this component may interact with an “open world” of external entities. If false, the component's domain of interaction is closed. For example, the world of a web search component is open, whereas that of a memory component is not.

    + */ + @JsonSetter(value = "openWorldHint", nulls = Nulls.SKIP) + public Builder openWorldHint(Optional openWorldHint) { + this.openWorldHint = openWorldHint; + return this; + } + + public Builder openWorldHint(Boolean openWorldHint) { + this.openWorldHint = Optional.ofNullable(openWorldHint); + return this; + } + + /** + *

    If true, the component does not modify its environment.

    + */ + @JsonSetter(value = "readOnlyHint", nulls = Nulls.SKIP) + public Builder readOnlyHint(Optional readOnlyHint) { + this.readOnlyHint = readOnlyHint; + return this; + } + + public Builder readOnlyHint(Boolean readOnlyHint) { + this.readOnlyHint = Optional.ofNullable(readOnlyHint); + return this; + } + + /** + *

    A human-readable title for the component.

    + */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + public ToolAnnotations build() { + return new ToolAnnotations( + destructiveHint, idempotentHint, openWorldHint, readOnlyHint, title, additionalProperties); + } + } +} diff --git a/src/test/java/com/pipedream/api/OauthTokensWireTest.java b/src/test/java/com/pipedream/api/OauthTokensWireTest.java new file mode 100644 index 0000000..88a6634 --- /dev/null +++ b/src/test/java/com/pipedream/api/OauthTokensWireTest.java @@ -0,0 +1,123 @@ +package com.pipedream.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.pipedream.api.core.ObjectMappers; +import com.pipedream.api.resources.oauthtokens.requests.CreateOAuthTokenOpts; +import com.pipedream.api.types.CreateOAuthTokenResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class OauthTokensWireTest { + private MockWebServer server; + private BaseClient client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseClient.builder() + .url(server.url("/").toString()) + .token("oauth-test-token") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testCreate() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"access_token\":\"access_token\",\"token_type\":\"token_type\",\"expires_in\":1}")); + CreateOAuthTokenResponse response = client.oauthTokens() + .create(CreateOAuthTokenOpts.builder() + .grantType("client_credentials") + .clientId("client_id") + .clientSecret("client_secret") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"grant_type\": \"client_credentials\",\n" + + " \"client_id\": \"client_id\",\n" + + " \"client_secret\": \"client_secret\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"access_token\": \"access_token\",\n" + + " \"token_type\": \"token_type\",\n" + + " \"expires_in\": 1\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/pipedream/api/TokensWireTest.java b/src/test/java/com/pipedream/api/TokensWireTest.java new file mode 100644 index 0000000..8ed94a9 --- /dev/null +++ b/src/test/java/com/pipedream/api/TokensWireTest.java @@ -0,0 +1,111 @@ +package com.pipedream.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.pipedream.api.core.ObjectMappers; +import com.pipedream.api.resources.tokens.requests.TokensValidateRequest; +import com.pipedream.api.types.ValidateTokenResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TokensWireTest { + private MockWebServer server; + private BaseClient client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseClient.builder() + .url(server.url("/").toString()) + .token("oauth-test-token") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testValidate() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"app\":{\"id\":\"id\",\"name_slug\":\"name_slug\",\"name\":\"name\",\"auth_type\":\"keys\",\"description\":\"description\",\"img_src\":\"img_src\",\"custom_fields_json\":\"custom_fields_json\",\"categories\":[\"categories\"],\"featured_weight\":1.1},\"error\":\"error\",\"error_redirect_uri\":\"error_redirect_uri\",\"oauth_app_id\":\"oauth_app_id\",\"project_app_name\":\"project_app_name\",\"project_environment\":\"project_environment\",\"project_id\":\"project_id\",\"project_support_email\":\"project_support_email\",\"success\":true,\"success_redirect_uri\":\"success_redirect_uri\"}")); + ValidateTokenResponse response = client.tokens() + .validate( + "ctok", + TokensValidateRequest.builder() + .appId("app_id") + .oauthAppId("oauth_app_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"app\": {\n" + + " \"id\": \"id\",\n" + + " \"name_slug\": \"name_slug\",\n" + + " \"name\": \"name\",\n" + + " \"auth_type\": \"keys\",\n" + + " \"description\": \"description\",\n" + + " \"img_src\": \"img_src\",\n" + + " \"custom_fields_json\": \"custom_fields_json\",\n" + + " \"categories\": [\n" + + " \"categories\"\n" + + " ],\n" + + " \"featured_weight\": 1.1\n" + + " },\n" + + " \"error\": \"error\",\n" + + " \"error_redirect_uri\": \"error_redirect_uri\",\n" + + " \"oauth_app_id\": \"oauth_app_id\",\n" + + " \"project_app_name\": \"project_app_name\",\n" + + " \"project_environment\": \"project_environment\",\n" + + " \"project_id\": \"project_id\",\n" + + " \"project_support_email\": \"project_support_email\",\n" + + " \"success\": true,\n" + + " \"success_redirect_uri\": \"success_redirect_uri\"\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +}