This is an automated email from the ASF dual-hosted git repository. jeremyross pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0267211e9b5bb1be8628331bb6ac07293e692037 Author: Jeremy Ross <jeremy.g.r...@gmail.com> AuthorDate: Fri Apr 15 10:21:42 2022 -0500 CAMEL-17719: camel-salesforce: Add operation to get event schemas Event schemas are Avro schemas and support Platform Events, Change Data Capture events, and custom events. --- .../salesforce/SalesforceComponentConfigurer.java | 18 +++++ .../salesforce/SalesforceEndpointConfigurer.java | 18 +++++ .../salesforce/SalesforceEndpointUriFactory.java | 5 +- .../camel/component/salesforce/salesforce.json | 84 ++++++++++++---------- .../src/main/docs/salesforce-component.adoc | 20 ++++++ .../component/salesforce/SalesforceEndpoint.java | 4 +- .../salesforce/SalesforceEndpointConfig.java | 55 +++++++++++++- .../component/salesforce/SalesforceProducer.java | 2 +- .../component/salesforce/api/utils/JsonUtils.java | 75 +++++++++++++++++-- .../salesforce/internal/OperationName.java | 1 + .../internal/client/DefaultRestClient.java | 37 ++++++++++ .../salesforce/internal/client/RestClient.java | 18 +++++ .../internal/dto/EventSchemaFormatEnum.java | 44 ++++++++++++ .../internal/processor/AbstractRestProcessor.java | 26 +++++++ .../internal/processor/SalesforceProcessor.java | 2 - .../salesforce/RestApiIntegrationTest.java | 32 +++++++++ 16 files changed, 391 insertions(+), 50 deletions(-) diff --git a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java index 41fe36cac2a..93e4abef2d8 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java +++ b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceComponentConfigurer.java @@ -59,6 +59,12 @@ public class SalesforceComponentConfigurer extends PropertyConfigurerSupport imp case "contentType": getOrCreateConfig(target).setContentType(property(camelContext, org.apache.camel.component.salesforce.api.dto.bulk.ContentType.class, value)); return true; case "defaultreplayid": case "defaultReplayId": getOrCreateConfig(target).setDefaultReplayId(property(camelContext, java.lang.Long.class, value)); return true; + case "eventname": + case "eventName": getOrCreateConfig(target).setEventName(property(camelContext, java.lang.String.class, value)); return true; + case "eventschemaformat": + case "eventSchemaFormat": getOrCreateConfig(target).setEventSchemaFormat(property(camelContext, org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum.class, value)); return true; + case "eventschemaid": + case "eventSchemaId": getOrCreateConfig(target).setEventSchemaId(property(camelContext, java.lang.String.class, value)); return true; case "fallbackreplayid": case "fallBackReplayId": getOrCreateConfig(target).setFallBackReplayId(property(camelContext, java.lang.Long.class, value)); return true; case "format": getOrCreateConfig(target).setFormat(property(camelContext, org.apache.camel.component.salesforce.internal.PayloadFormat.class, value)); return true; @@ -255,6 +261,12 @@ public class SalesforceComponentConfigurer extends PropertyConfigurerSupport imp case "contentType": return org.apache.camel.component.salesforce.api.dto.bulk.ContentType.class; case "defaultreplayid": case "defaultReplayId": return java.lang.Long.class; + case "eventname": + case "eventName": return java.lang.String.class; + case "eventschemaformat": + case "eventSchemaFormat": return org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum.class; + case "eventschemaid": + case "eventSchemaId": return java.lang.String.class; case "fallbackreplayid": case "fallBackReplayId": return java.lang.Long.class; case "format": return org.apache.camel.component.salesforce.internal.PayloadFormat.class; @@ -452,6 +464,12 @@ public class SalesforceComponentConfigurer extends PropertyConfigurerSupport imp case "contentType": return getOrCreateConfig(target).getContentType(); case "defaultreplayid": case "defaultReplayId": return getOrCreateConfig(target).getDefaultReplayId(); + case "eventname": + case "eventName": return getOrCreateConfig(target).getEventName(); + case "eventschemaformat": + case "eventSchemaFormat": return getOrCreateConfig(target).getEventSchemaFormat(); + case "eventschemaid": + case "eventSchemaId": return getOrCreateConfig(target).getEventSchemaId(); case "fallbackreplayid": case "fallBackReplayId": return getOrCreateConfig(target).getFallBackReplayId(); case "format": return getOrCreateConfig(target).getFormat(); diff --git a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigurer.java b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigurer.java index e58c53ad0d8..cd06d67e5e1 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigurer.java +++ b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointConfigurer.java @@ -43,6 +43,12 @@ public class SalesforceEndpointConfigurer extends PropertyConfigurerSupport impl case "contentType": target.getConfiguration().setContentType(property(camelContext, org.apache.camel.component.salesforce.api.dto.bulk.ContentType.class, value)); return true; case "defaultreplayid": case "defaultReplayId": target.getConfiguration().setDefaultReplayId(property(camelContext, java.lang.Long.class, value)); return true; + case "eventname": + case "eventName": target.getConfiguration().setEventName(property(camelContext, java.lang.String.class, value)); return true; + case "eventschemaformat": + case "eventSchemaFormat": target.getConfiguration().setEventSchemaFormat(property(camelContext, org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum.class, value)); return true; + case "eventschemaid": + case "eventSchemaId": target.getConfiguration().setEventSchemaId(property(camelContext, java.lang.String.class, value)); return true; case "exceptionhandler": case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; case "exchangepattern": @@ -173,6 +179,12 @@ public class SalesforceEndpointConfigurer extends PropertyConfigurerSupport impl case "contentType": return org.apache.camel.component.salesforce.api.dto.bulk.ContentType.class; case "defaultreplayid": case "defaultReplayId": return java.lang.Long.class; + case "eventname": + case "eventName": return java.lang.String.class; + case "eventschemaformat": + case "eventSchemaFormat": return org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum.class; + case "eventschemaid": + case "eventSchemaId": return java.lang.String.class; case "exceptionhandler": case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class; case "exchangepattern": @@ -304,6 +316,12 @@ public class SalesforceEndpointConfigurer extends PropertyConfigurerSupport impl case "contentType": return target.getConfiguration().getContentType(); case "defaultreplayid": case "defaultReplayId": return target.getConfiguration().getDefaultReplayId(); + case "eventname": + case "eventName": return target.getConfiguration().getEventName(); + case "eventschemaformat": + case "eventSchemaFormat": return target.getConfiguration().getEventSchemaFormat(); + case "eventschemaid": + case "eventSchemaId": return target.getConfiguration().getEventSchemaId(); case "exceptionhandler": case "exceptionHandler": return target.getExceptionHandler(); case "exchangepattern": diff --git a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointUriFactory.java b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointUriFactory.java index c9c22e45cd6..eef07fb409a 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointUriFactory.java +++ b/components/camel-salesforce/camel-salesforce-component/src/generated/java/org/apache/camel/component/salesforce/SalesforceEndpointUriFactory.java @@ -21,7 +21,7 @@ public class SalesforceEndpointUriFactory extends org.apache.camel.support.compo private static final Set<String> SECRET_PROPERTY_NAMES; private static final Set<String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(65); + Set<String> props = new HashSet<>(68); props.add("allOrNone"); props.add("apexMethod"); props.add("apexQueryParams"); @@ -33,6 +33,9 @@ public class SalesforceEndpointUriFactory extends org.apache.camel.support.compo props.add("compositeMethod"); props.add("contentType"); props.add("defaultReplayId"); + props.add("eventName"); + props.add("eventSchemaFormat"); + props.add("eventSchemaId"); props.add("exceptionHandler"); props.add("exchangePattern"); props.add("fallBackReplayId"); diff --git a/components/camel-salesforce/camel-salesforce-component/src/generated/resources/org/apache/camel/component/salesforce/salesforce.json b/components/camel-salesforce/camel-salesforce-component/src/generated/resources/org/apache/camel/component/salesforce/salesforce.json index 959c872f7d4..858cda6d268 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/generated/resources/org/apache/camel/component/salesforce/salesforce.json +++ b/components/camel-salesforce/camel-salesforce-component/src/generated/resources/org/apache/camel/component/salesforce/salesforce.json @@ -89,39 +89,42 @@ "allOrNone": { "index": 62, "kind": "property", "displayName": "All Or None", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Composite API option to indicate to rollback all records if any are not successful." }, "apexUrl": { "index": 63, "kind": "property", "displayName": "Apex Url", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "APEX method URL" }, "compositeMethod": { "index": 64, "kind": "property", "displayName": "Composite Method", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Composite (raw) method." }, - "lazyStartProducer": { "index": 65, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fai [...] - "rawHttpHeaders": { "index": 66, "kind": "property", "displayName": "Raw Http Headers", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Comma separated list of message headers to include as HTTP parameters for Raw operation." }, - "rawMethod": { "index": 67, "kind": "property", "displayName": "Raw Method", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "HTTP method to use for the Raw operation" }, - "rawPath": { "index": 68, "kind": "property", "displayName": "Raw Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "The portion of the endpoint URL after the domain name. E.g., '\/services\/data\/v52.0\/sobjects\/Account\/'" }, - "rawQueryParameters": { "index": 69, "kind": "property", "displayName": "Raw Query Parameters", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Comma separated list of message headers to include as query parameters for Raw operatio [...] - "autowiredEnabled": { "index": 70, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...] - "httpProxyExcludedAddresses": { "index": 71, "kind": "property", "displayName": "Http Proxy Excluded Addresses", "group": "proxy", "label": "common,proxy", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A list of addresses for which HTTP proxy server should not be used." }, - "httpProxyHost": { "index": 72, "kind": "property", "displayName": "Http Proxy Host", "group": "proxy", "label": "common,proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Hostname of the HTTP proxy server to use." }, - "httpProxyIncludedAddresses": { "index": 73, "kind": "property", "displayName": "Http Proxy Included Addresses", "group": "proxy", "label": "common,proxy", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A list of addresses for which HTTP proxy server should be used." }, - "httpProxyPort": { "index": 74, "kind": "property", "displayName": "Http Proxy Port", "group": "proxy", "label": "common,proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Port number of the HTTP proxy server to use." }, - "httpProxySocks4": { "index": 75, "kind": "property", "displayName": "Http Proxy Socks4", "group": "proxy", "label": "common,proxy", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true the configures the HTTP proxy to use as a SOCKS4 proxy." }, - "authenticationType": { "index": 76, "kind": "property", "displayName": "Authentication Type", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.AuthenticationType", "enum": [ "USERNAME_PASSWORD", "REFRESH_TOKEN", "JWT" ], "deprecated": false, "autowired": false, "secret": false, "description": "Explicit authentication method to be used, one of USERNAME_PASSWORD, REFRESH_TOKEN or JWT. Salesforce co [...] - "clientId": { "index": 77, "kind": "property", "displayName": "Client Id", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth Consumer Key of the connected app configured in the Salesforce instance setup. Typically a connected app needs to be configured but one can be provided by installing a package." }, - "clientSecret": { "index": 78, "kind": "property", "displayName": "Client Secret", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth Consumer Secret of the connected app configured in the Salesforce instance setup." }, - "httpProxyAuthUri": { "index": 79, "kind": "property", "displayName": "Http Proxy Auth Uri", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Used in authentication against the HTTP proxy server, needs to match the URI of the proxy server in order for the httpProxyUsername and httpProxyPassword to be used for authentication." }, - "httpProxyPassword": { "index": 80, "kind": "property", "displayName": "Http Proxy Password", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password to use to authenticate against the HTTP proxy server." }, - "httpProxyRealm": { "index": 81, "kind": "property", "displayName": "Http Proxy Realm", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Realm of the proxy server, used in preemptive Basic\/Digest authentication methods against the HTTP proxy server." }, - "httpProxySecure": { "index": 82, "kind": "property", "displayName": "Http Proxy Secure", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If set to false disables the use of TLS when accessing the HTTP proxy." }, - "httpProxyUseDigestAuth": { "index": 83, "kind": "property", "displayName": "Http Proxy Use Digest Auth", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true Digest authentication will be used when authenticating to the HTTP proxy, otherwise Basic authorization method will be used" }, - "httpProxyUsername": { "index": 84, "kind": "property", "displayName": "Http Proxy Username", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username to use to authenticate against the HTTP proxy server." }, - "instanceUrl": { "index": 85, "kind": "property", "displayName": "Instance Url", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "URL of the Salesforce instance used after authentication, by default received from Salesforce on successful authentication" }, - "jwtAudience": { "index": 86, "kind": "property", "displayName": "Jwt Audience", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Value to use for the Audience claim (aud) when using OAuth JWT flow. If not set, the login URL will be used, which is appropriate in most cases." }, - "keystore": { "index": 87, "kind": "property", "displayName": "Keystore", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.KeyStoreParameters", "deprecated": false, "autowired": false, "secret": true, "description": "KeyStore parameters to use in OAuth JWT flow. The KeyStore should contain only one entry with private key and certificate. Salesforce does not verify the certificate chain, so this can easily [...] - "lazyLogin": { "index": 88, "kind": "property", "displayName": "Lazy Login", "group": "security", "label": "common,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true prevents the component from authenticating to Salesforce with the start of the component. You would generally set this to the (default) false and authenticate early and be immediately aware [...] - "loginConfig": { "index": 89, "kind": "property", "displayName": "Login Config", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.SalesforceLoginConfig", "deprecated": false, "autowired": false, "secret": false, "description": "All authentication configuration in one nested bean, all properties set there can be set directly on the component as well" }, - "loginUrl": { "index": 90, "kind": "property", "displayName": "Login Url", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https:\/\/login.salesforce.com", "description": "URL of the Salesforce instance used for authentication, by default set to https:\/\/login.salesforce.com" }, - "password": { "index": 91, "kind": "property", "displayName": "Password", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows. Make sure that you append secur [...] - "pubSubHost": { "index": 92, "kind": "property", "displayName": "Pub Sub Host", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "api.pubsub.salesforce.com", "description": "Pub\/Sub host" }, - "pubSubPort": { "index": 93, "kind": "property", "displayName": "Pub Sub Port", "group": "security", "label": "common,security", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 7443, "description": "Pub\/Sub port" }, - "refreshToken": { "index": 94, "kind": "property", "displayName": "Refresh Token", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Refresh token already obtained in the refresh token OAuth flow. One needs to setup a web application and configure a callback URL to receive the refresh token, or configure using the builtin callback at https:\/\/l [...] - "sslContextParameters": { "index": 95, "kind": "property", "displayName": "Ssl Context Parameters", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "SSL parameters to use, see SSLContextParameters class for all available options." }, - "useGlobalSslContextParameters": { "index": 96, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters" }, - "userName": { "index": 97, "kind": "property", "displayName": "User Name", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows." } + "eventName": { "index": 65, "kind": "property", "displayName": "Event Name", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Name of Platform Event, Change Data Capture Event, custom event, etc." }, + "eventSchemaFormat": { "index": 66, "kind": "property", "displayName": "Event Schema Format", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum", "enum": [ "EXPANDED", "COMPACT" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": [...] + "eventSchemaId": { "index": 67, "kind": "property", "displayName": "Event Schema Id", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "The ID of the event schema." }, + "lazyStartProducer": { "index": 68, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fai [...] + "rawHttpHeaders": { "index": 69, "kind": "property", "displayName": "Raw Http Headers", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Comma separated list of message headers to include as HTTP parameters for Raw operation." }, + "rawMethod": { "index": 70, "kind": "property", "displayName": "Raw Method", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "HTTP method to use for the Raw operation" }, + "rawPath": { "index": 71, "kind": "property", "displayName": "Raw Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "The portion of the endpoint URL after the domain name. E.g., '\/services\/data\/v52.0\/sobjects\/Account\/'" }, + "rawQueryParameters": { "index": 72, "kind": "property", "displayName": "Raw Query Parameters", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "config", "description": "Comma separated list of message headers to include as query parameters for Raw operatio [...] + "autowiredEnabled": { "index": 73, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...] + "httpProxyExcludedAddresses": { "index": 74, "kind": "property", "displayName": "Http Proxy Excluded Addresses", "group": "proxy", "label": "common,proxy", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A list of addresses for which HTTP proxy server should not be used." }, + "httpProxyHost": { "index": 75, "kind": "property", "displayName": "Http Proxy Host", "group": "proxy", "label": "common,proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Hostname of the HTTP proxy server to use." }, + "httpProxyIncludedAddresses": { "index": 76, "kind": "property", "displayName": "Http Proxy Included Addresses", "group": "proxy", "label": "common,proxy", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A list of addresses for which HTTP proxy server should be used." }, + "httpProxyPort": { "index": 77, "kind": "property", "displayName": "Http Proxy Port", "group": "proxy", "label": "common,proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Port number of the HTTP proxy server to use." }, + "httpProxySocks4": { "index": 78, "kind": "property", "displayName": "Http Proxy Socks4", "group": "proxy", "label": "common,proxy", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true the configures the HTTP proxy to use as a SOCKS4 proxy." }, + "authenticationType": { "index": 79, "kind": "property", "displayName": "Authentication Type", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.AuthenticationType", "enum": [ "USERNAME_PASSWORD", "REFRESH_TOKEN", "JWT" ], "deprecated": false, "autowired": false, "secret": false, "description": "Explicit authentication method to be used, one of USERNAME_PASSWORD, REFRESH_TOKEN or JWT. Salesforce co [...] + "clientId": { "index": 80, "kind": "property", "displayName": "Client Id", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "OAuth Consumer Key of the connected app configured in the Salesforce instance setup. Typically a connected app needs to be configured but one can be provided by installing a package." }, + "clientSecret": { "index": 81, "kind": "property", "displayName": "Client Secret", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "OAuth Consumer Secret of the connected app configured in the Salesforce instance setup." }, + "httpProxyAuthUri": { "index": 82, "kind": "property", "displayName": "Http Proxy Auth Uri", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Used in authentication against the HTTP proxy server, needs to match the URI of the proxy server in order for the httpProxyUsername and httpProxyPassword to be used for authentication." }, + "httpProxyPassword": { "index": 83, "kind": "property", "displayName": "Http Proxy Password", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password to use to authenticate against the HTTP proxy server." }, + "httpProxyRealm": { "index": 84, "kind": "property", "displayName": "Http Proxy Realm", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Realm of the proxy server, used in preemptive Basic\/Digest authentication methods against the HTTP proxy server." }, + "httpProxySecure": { "index": 85, "kind": "property", "displayName": "Http Proxy Secure", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If set to false disables the use of TLS when accessing the HTTP proxy." }, + "httpProxyUseDigestAuth": { "index": 86, "kind": "property", "displayName": "Http Proxy Use Digest Auth", "group": "security", "label": "common,proxy,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true Digest authentication will be used when authenticating to the HTTP proxy, otherwise Basic authorization method will be used" }, + "httpProxyUsername": { "index": 87, "kind": "property", "displayName": "Http Proxy Username", "group": "security", "label": "common,proxy,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username to use to authenticate against the HTTP proxy server." }, + "instanceUrl": { "index": 88, "kind": "property", "displayName": "Instance Url", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "URL of the Salesforce instance used after authentication, by default received from Salesforce on successful authentication" }, + "jwtAudience": { "index": 89, "kind": "property", "displayName": "Jwt Audience", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Value to use for the Audience claim (aud) when using OAuth JWT flow. If not set, the login URL will be used, which is appropriate in most cases." }, + "keystore": { "index": 90, "kind": "property", "displayName": "Keystore", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.KeyStoreParameters", "deprecated": false, "autowired": false, "secret": true, "description": "KeyStore parameters to use in OAuth JWT flow. The KeyStore should contain only one entry with private key and certificate. Salesforce does not verify the certificate chain, so this can easily [...] + "lazyLogin": { "index": 91, "kind": "property", "displayName": "Lazy Login", "group": "security", "label": "common,security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true prevents the component from authenticating to Salesforce with the start of the component. You would generally set this to the (default) false and authenticate early and be immediately aware [...] + "loginConfig": { "index": 92, "kind": "property", "displayName": "Login Config", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.SalesforceLoginConfig", "deprecated": false, "autowired": false, "secret": false, "description": "All authentication configuration in one nested bean, all properties set there can be set directly on the component as well" }, + "loginUrl": { "index": 93, "kind": "property", "displayName": "Login Url", "group": "security", "label": "common,security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https:\/\/login.salesforce.com", "description": "URL of the Salesforce instance used for authentication, by default set to https:\/\/login.salesforce.com" }, + "password": { "index": 94, "kind": "property", "displayName": "Password", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Password used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows. Make sure that you append secur [...] + "pubSubHost": { "index": 95, "kind": "property", "displayName": "Pub Sub Host", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "api.pubsub.salesforce.com", "description": "Pub\/Sub host" }, + "pubSubPort": { "index": 96, "kind": "property", "displayName": "Pub Sub Port", "group": "security", "label": "common,security", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 7443, "description": "Pub\/Sub port" }, + "refreshToken": { "index": 97, "kind": "property", "displayName": "Refresh Token", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "Refresh token already obtained in the refresh token OAuth flow. One needs to setup a web application and configure a callback URL to receive the refresh token, or configure using the builtin callback at https:\/\/l [...] + "sslContextParameters": { "index": 98, "kind": "property", "displayName": "Ssl Context Parameters", "group": "security", "label": "common,security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "SSL parameters to use, see SSLContextParameters class for all available options." }, + "useGlobalSslContextParameters": { "index": 99, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters" }, + "userName": { "index": 100, "kind": "property", "displayName": "User Name", "group": "security", "label": "common,security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Username used in OAuth flow to gain access to access token. It's easy to get started with password OAuth flow, but in general one should avoid it as it is deemed less secure than other flows." } }, "headers": { "CamelSalesforceReplayId": { "index": 0, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Streaming API replayId.", "constantName": "org.apache.camel.component.salesforce.SalesforceConstants#HEADER_SALESFORCE_REPLAY_ID" }, @@ -146,7 +149,7 @@ "CamelSalesforceQueryResultTotalSize": { "index": 19, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Total number of records matching a query.", "constantName": "org.apache.camel.component.salesforce.SalesforceConstants#HEADER_SALESFORCE_QUERY_RESULT_TOTAL_SIZE" } }, "properties": { - "operationName": { "index": 0, "kind": "path", "displayName": "Operation Name", "group": "common", "label": "common", "required": true, "type": "object", "javaType": "org.apache.camel.component.salesforce.internal.OperationName", "enum": [ "getVersions", "getResources", "getGlobalObjects", "getBasicInfo", "getDescription", "getSObject", "createSObject", "updateSObject", "deleteSObject", "getSObjectWithId", "upsertSObject", "deleteSObjectWithId", "getBlobField", "query", "queryMore", [...] + "operationName": { "index": 0, "kind": "path", "displayName": "Operation Name", "group": "common", "label": "common", "required": true, "type": "object", "javaType": "org.apache.camel.component.salesforce.internal.OperationName", "enum": [ "getVersions", "getResources", "getGlobalObjects", "getBasicInfo", "getDescription", "getSObject", "createSObject", "updateSObject", "deleteSObject", "getSObjectWithId", "upsertSObject", "deleteSObjectWithId", "getBlobField", "query", "queryMore", [...] "topicName": { "index": 1, "kind": "path", "displayName": "Topic Name", "group": "producer", "label": "consumer,producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the topic\/channel to use" }, "apexMethod": { "index": 2, "kind": "parameter", "displayName": "Apex Method", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "APEX method name" }, "apexQueryParams": { "index": 3, "kind": "parameter", "displayName": "Apex Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Query params for APEX method" }, @@ -206,10 +209,13 @@ "allOrNone": { "index": 57, "kind": "parameter", "displayName": "All Or None", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Composite API option to indicate to rollback all records if any are not successful." }, "apexUrl": { "index": 58, "kind": "parameter", "displayName": "Apex Url", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "APEX method URL" }, "compositeMethod": { "index": 59, "kind": "parameter", "displayName": "Composite Method", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Composite (raw) method." }, - "rawHttpHeaders": { "index": 60, "kind": "parameter", "displayName": "Raw Http Headers", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Comma separated list of message headers to include as HTTP parameters for Raw operation." }, - "rawMethod": { "index": 61, "kind": "parameter", "displayName": "Raw Method", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "HTTP method to use for the Raw operation" }, - "rawPath": { "index": 62, "kind": "parameter", "displayName": "Raw Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "The portion of the endpoint URL after the domain name. E.g., '\/services\/data\/v52.0\/sobjects\/Accou [...] - "rawQueryParameters": { "index": 63, "kind": "parameter", "displayName": "Raw Query Parameters", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Comma separated list of message headers to include as query parameters for Raw [...] - "lazyStartProducer": { "index": 64, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] + "eventName": { "index": 60, "kind": "parameter", "displayName": "Event Name", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Name of Platform Event, Change Data Capture Event, custom event, etc." }, + "eventSchemaFormat": { "index": 61, "kind": "parameter", "displayName": "Event Schema Format", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum", "enum": [ "EXPANDED", "COMPACT" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "descr [...] + "eventSchemaId": { "index": 62, "kind": "parameter", "displayName": "Event Schema Id", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "The ID of the event schema." }, + "rawHttpHeaders": { "index": 63, "kind": "parameter", "displayName": "Raw Http Headers", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Comma separated list of message headers to include as HTTP parameters for Raw operation." }, + "rawMethod": { "index": 64, "kind": "parameter", "displayName": "Raw Method", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "HTTP method to use for the Raw operation" }, + "rawPath": { "index": 65, "kind": "parameter", "displayName": "Raw Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "The portion of the endpoint URL after the domain name. E.g., '\/services\/data\/v52.0\/sobjects\/Accou [...] + "rawQueryParameters": { "index": 66, "kind": "parameter", "displayName": "Raw Query Parameters", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.salesforce.SalesforceEndpointConfig", "configurationField": "configuration", "description": "Comma separated list of message headers to include as query parameters for Raw [...] + "lazyStartProducer": { "index": 67, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] } } diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc index 3fb381fb74e..9ad13e05c4e 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc +++ b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc @@ -225,6 +225,7 @@ request as the input to a subsequent request. * <<compositeUpdateSObjectCollections,compositeUpdateSObjectCollections>> - Update up to 200 records. * <<compositeUpsertSObjectCollections,compositeUpsertSObjectCollections>> - Creates or updates up to 200 records based on an External Id field. * <<compositeDeleteSObjectCollections,compositeDeleteSObjectCollections>> - Deletes up to 200 records. +* <<getEventSchema, getEventSchema>> - Gets the event schema for Plaform Events, Change Data Capture events, etc. Unless otherwise specified, DTO types for the following options are from `org.apache.camel.component.salesforce.api.dto` or one if its sub-packages. @@ -997,6 +998,25 @@ Delete up to 200 records. Mixed SObject types is supported. Type: `List<DeleteSObjectResult>` +[[getEventSchema]] +==== Get Event Schema + +`getEventSchema` + +Gets the definition of a Platform Event in JSON format. Other types of events such as Change Data Capture events or custom events are also supported. This operation is available in REST API version 40.0 and later. + +|=== +| Parameter | Type | Description | Default | Required + +| `eventName` | String | Name of event | | `eventName` or `eventSchemaId` is required +| `eventSchemaId` | String | ID of a schema | | `eventName` or `eventSchemaId` is required +| `eventSchemaFormat` | EventSchemaFormatEnum | `EXPANDED`: Apache Avro format but doesn’t strictly adhere to the record complex type. `COMPACT`: Apache Avro, adheres to the specification for the record complex type. This parameter is available in API version 43.0 and later. | `EXPANDED` | +|=== + +*Output* + +Type: `InputStream` + [[ApexRESTAPI]] === Apex REST API diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpoint.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpoint.java index 55ec2080469..bd35c02d620 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpoint.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpoint.java @@ -44,8 +44,8 @@ public class SalesforceEndpoint extends DefaultEndpoint { @UriPath(label = "common", description = "The operation to use", enums = "getVersions," + "getResources,getGlobalObjects,getBasicInfo,getDescription,getSObject,createSObject," + "updateSObject,deleteSObject,getSObjectWithId,upsertSObject,deleteSObjectWithId," - + "getBlobField,query,queryMore,queryAll,search,apexCall,recent,createJob,getJob," - + "closeJob,abortJob,createBatch,getBatch,getAllBatches,getRequest,getResults," + + "getBlobField,query,queryMore,queryAll,search,apexCall,recent,getEventSchema,createJob," + + "getJob,closeJob,abortJob,createBatch,getBatch,getAllBatches,getRequest,getResults," + "createBatchQuery,getQueryResultIds,getQueryResult,getRecentReports," + "getReportDescription,executeSyncReport,executeAsyncReport,getReportInstances," + "getReportResults,limits,approval,approvals,composite-tree,composite-batch,composite," diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java index cf05df142b1..2db0e7c24ee 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java @@ -30,6 +30,7 @@ import org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest; import org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest.Action; import org.apache.camel.component.salesforce.api.dto.bulk.ContentType; import org.apache.camel.component.salesforce.internal.PayloadFormat; +import org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum; import org.apache.camel.component.salesforce.internal.dto.NotifyForFieldsEnum; import org.apache.camel.component.salesforce.internal.dto.NotifyForOperationsEnum; import org.apache.camel.spi.UriParam; @@ -67,6 +68,9 @@ public class SalesforceEndpointConfig implements Cloneable { public static final String COMPOSITE_METHOD = "compositeMethod"; public static final String LIMIT = "limit"; public static final String ALL_OR_NONE = "allOrNone"; + public static final String EVENT_NAME = "eventName"; + public static final String EVENT_SCHEMA_ID = "eventSchemaId"; + public static final String EVENT_SCHEMA_FORMAT = "eventSchemaFormat"; // prefix for parameters in headers public static final String APEX_QUERY_PARAM_PREFIX = "apexQueryParam."; @@ -151,6 +155,12 @@ public class SalesforceEndpointConfig implements Cloneable { private String sObjectSearch; @UriParam private String apexMethod; + @UriParam(displayName = "Event Name", label = "producer") + private String eventName; + @UriParam(displayName = "Event Schema Format", label = "producer") + private EventSchemaFormatEnum eventSchemaFormat; + @UriParam(displayName = "Event Schema Id", label = "producer") + private String eventSchemaId; @UriParam(label = "producer") private String compositeMethod; @UriParam(label = "producer", defaultValue = "false", description = "Composite API option to indicate" + @@ -813,10 +823,13 @@ public class SalesforceEndpointConfig implements Cloneable { valueMap.put(SOBJECT_SEARCH, sObjectSearch); valueMap.put(APEX_METHOD, apexMethod); valueMap.put(APEX_URL, apexUrl); + // apexQueryParams are handled explicitly in AbstractRestProcessor valueMap.put(COMPOSITE_METHOD, compositeMethod); valueMap.put(LIMIT, limit); valueMap.put(APPROVAL, approval); - // apexQueryParams are handled explicitly in AbstractRestProcessor + valueMap.put(EVENT_NAME, eventName); + valueMap.put(EVENT_SCHEMA_FORMAT, eventSchemaFormat); + valueMap.put(EVENT_SCHEMA_ID, eventSchemaId); // add bulk API properties if (contentType != null) { @@ -1174,4 +1187,44 @@ public class SalesforceEndpointConfig implements Cloneable { this.pubSubBatchSize = pubSubBatchSize; } + public String getEventName() { + return eventName; + } + + /** + * Name of Platform Event, Change Data Capture Event, custom event, etc. + * + * @param eventName + */ + public void setEventName(String eventName) { + this.eventName = eventName; + } + + public EventSchemaFormatEnum getEventSchemaFormat() { + return eventSchemaFormat; + } + + /** + * EXPANDED: Apache Avro format but doesn’t strictly adhere to the record complex type. COMPACT: Apache Avro, + * adheres to the specification for the record complex type. This parameter is available in API version 43.0 and + * later. + * + * @param eventSchemaFormat + */ + public void setEventSchemaFormat(EventSchemaFormatEnum eventSchemaFormat) { + this.eventSchemaFormat = eventSchemaFormat; + } + + public String getEventSchemaId() { + return eventSchemaId; + } + + /** + * The ID of the event schema. + * + * @param eventSchemaId + */ + public void setEventSchemaId(String eventSchemaId) { + this.eventSchemaId = eventSchemaId; + } } diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceProducer.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceProducer.java index 6ef4ff027f8..77a12e7c060 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceProducer.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceProducer.java @@ -48,7 +48,7 @@ public class SalesforceProducer extends DefaultAsyncProducer { public SalesforceProducer(SalesforceEndpoint endpoint) throws SalesforceException { super(endpoint); - // check if its a Bulk Operation + // check if it's a Bulk Operation final OperationName operationName = endpoint.getOperationName(); if (isBulkOperation(operationName)) { processor = new BulkApiProcessor(endpoint); diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/JsonUtils.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/JsonUtils.java index 3c7a134372b..3d1d1511797 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/JsonUtils.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/utils/JsonUtils.java @@ -148,18 +148,20 @@ public final class JsonUtils { throws JsonProcessingException { ObjectMapper schemaObjectMapper = createSchemaObjectMapper(); return getJsonSchemaString(schemaObjectMapper, - getSObjectJsonSchema(schemaObjectMapper, description, DEFAULT_ID_PREFIX, addQuerySchema), DEFAULT_ID_PREFIX); + getSObjectJsonSchema(schemaObjectMapper, description, DEFAULT_ID_PREFIX, addQuerySchema, false), + DEFAULT_ID_PREFIX); } public static JsonSchema getSObjectJsonSchemaAsSchema(SObjectDescription description, boolean addQuerySchema) throws JsonProcessingException { ObjectMapper schemaObjectMapper = createSchemaObjectMapper(); - return getJsonSchemaAsSchema(getSObjectJsonSchema(schemaObjectMapper, description, DEFAULT_ID_PREFIX, addQuerySchema), + return getJsonSchemaAsSchema( + getSObjectJsonSchema(schemaObjectMapper, description, DEFAULT_ID_PREFIX, addQuerySchema, false), DEFAULT_ID_PREFIX); } public static Set<JsonSchema> getSObjectJsonSchema( - ObjectMapper objectMapper, SObjectDescription description, String idPrefix, boolean addQuerySchema) + ObjectMapper objectMapper, SObjectDescription description, String idPrefix, boolean addQuerySchema, boolean forCdc) throws JsonProcessingException { Set<JsonSchema> allSchemas = new HashSet<>(); @@ -280,7 +282,7 @@ public final class JsonUtils { fieldSchema.setDescription(descriptionText); // add property to sobject schema - if (field.isNillable()) { + if (field.isNillable() || forCdc) { sobjectSchema.putOptionalProperty(field.getName(), fieldSchema); } else { sobjectSchema.putProperty(field.getName(), fieldSchema); @@ -308,6 +310,71 @@ public final class JsonUtils { return allSchemas; } + public static JsonSchema getCdcSchema( + ObjectMapper objectMapper, Iterable<SObjectDescription> descriptions, + String idPrefix) + throws JsonProcessingException { + ObjectSchema cdcSchema = new ObjectSchema(); + cdcSchema.set$schema(SCHEMA4); + cdcSchema.setId(idPrefix + ":cdc"); + cdcSchema.setTitle("CDC Change Events"); + + ObjectSchema header = new ObjectSchema(); + header.putProperty("entityName", new StringSchema()); + + ArraySchema recordIds = new ArraySchema(); + recordIds.setItems(new ArraySchema.SingleItems(new StringSchema())); + header.putProperty("recordIds", recordIds); + + ArraySchema changedFields = new ArraySchema(); + changedFields.setItems(new ArraySchema.SingleItems(new StringSchema())); + header.putProperty("changedFields", changedFields); + + StringSchema changeType = new StringSchema(); + changeType.setEnums(Set.of( + "CREATE", + "UPDATE", + "DELETE", + "UNDELETE", + "GAP_CREATE", + "GAP_UPDATE", + "GAP_DELETE", + "GAP_UNDELETE", + "GAP_OVERFLOW")); + header.putProperty("changeType", changeType); + + header.putProperty("changeOrigin", new StringSchema()); + header.putProperty("transactionKey", new StringSchema()); + header.putProperty("sequenceNumber", new IntegerSchema()); + header.putProperty("commitTimestamp", new IntegerSchema()); + header.putProperty("commitUser", new StringSchema()); + header.putProperty("commitNumber", new IntegerSchema()); + + ObjectSchema data = new ObjectSchema(); + data.putProperty("schema", new StringSchema()); + + ObjectSchema event = new ObjectSchema(); + event.putProperty("replayId", new IntegerSchema()); + data.putProperty("event", event); + + cdcSchema.putProperty("data", data); + cdcSchema.putProperty("channel", new StringSchema()); + + Set<Object> sObjectSchemas = new HashSet<>(); + for (SObjectDescription d : descriptions) { + final ObjectSchema schema + = (ObjectSchema) getSObjectJsonSchema(objectMapper, d, idPrefix, false, true).toArray()[0]; + schema.putProperty("ChangeEventHeader", header); + sObjectSchemas.add(schema); + } + + ObjectSchema payload = new ObjectSchema(); + payload.setOneOf(sObjectSchemas); + data.putProperty("payload", payload); + + return cdcSchema; + } + public static ObjectMapper createSchemaObjectMapper() { ObjectMapper objectMapper = createObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true); diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/OperationName.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/OperationName.java index ea87d77b600..f6c24e7a29b 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/OperationName.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/OperationName.java @@ -41,6 +41,7 @@ public enum OperationName { SEARCH("search"), APEX_CALL("apexCall"), RECENT("recent"), + GET_EVENT_SCHEMA("getEventSchema"), // bulk API CREATE_JOB("createJob"), diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultRestClient.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultRestClient.java index 1722e00b76a..c88de491804 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultRestClient.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultRestClient.java @@ -29,6 +29,7 @@ import java.util.Optional; import org.apache.camel.component.salesforce.SalesforceHttpClient; import org.apache.camel.component.salesforce.SalesforceLoginConfig; import org.apache.camel.component.salesforce.api.SalesforceException; +import org.apache.camel.component.salesforce.api.utils.Version; import org.apache.camel.component.salesforce.internal.SalesforceSession; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.URISupport; @@ -43,6 +44,7 @@ public class DefaultRestClient extends AbstractClientBase implements RestClient private static final String TOKEN_HEADER = "Authorization"; private static final String TOKEN_PREFIX = "Bearer "; private static final String SERVICES_APEXREST = "/services/apexrest/"; + private static final String GET_SCHEMA_MINIMUM_VERSION = "40.0"; public DefaultRestClient(final SalesforceHttpClient httpClient, final String version, final SalesforceSession session, @@ -344,6 +346,34 @@ public class DefaultRestClient extends AbstractClientBase implements RestClient } } + @Override + public void getEventSchemaByEventName( + String eventName, String payloadFormat, Map<String, List<String>> headers, ResponseCallback callback) { + validateMinimumVersion(GET_SCHEMA_MINIMUM_VERSION); + final Request request; + request = getRequest(HttpMethod.GET, sobjectsUrl(eventName) + "/eventSchema" + "?payloadFormat=" + payloadFormat, + headers); + + // requires authorization token + setAccessToken(request); + + doHttpRequest(request, new DelegatingClientCallback(callback)); + } + + @Override + public void getEventSchemaBySchemaId( + String schemaId, String payloadFormat, Map<String, List<String>> headers, ResponseCallback callback) { + validateMinimumVersion(GET_SCHEMA_MINIMUM_VERSION); + final Request request; + request = getRequest(HttpMethod.GET, versionUrl() + "event/eventSchema/" + schemaId + "?payloadFormat=" + payloadFormat, + headers); + + // requires authorization token + setAccessToken(request); + + doHttpRequest(request, new DelegatingClientCallback(callback)); + } + private String apexCallUrl(String apexUrl, Map<String, Object> queryParams) throws UnsupportedEncodingException, URISyntaxException { @@ -380,6 +410,13 @@ public class DefaultRestClient extends AbstractClientBase implements RestClient return instanceUrl + SERVICES_DATA; } + private void validateMinimumVersion(String minimumVersion) { + if (Version.create(version).compareTo(Version.create(minimumVersion)) < 0) { + throw new IllegalArgumentException( + "Salesforce API version " + minimumVersion + " or newer is required, version " + version + " was detected"); + } + } + private String versionUrl() { ObjectHelper.notNull(version, "version"); return servicesDataUrl() + "v" + version + "/"; diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/RestClient.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/RestClient.java index 53c2e921c44..c8bf525ff1a 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/RestClient.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/RestClient.java @@ -250,4 +250,22 @@ public interface RestClient { * @param callback {@link ResponseCallback} to handle response or exception */ void approvals(Map<String, List<String>> headers, ResponseCallback callback); + + /** + * + * @param eventName Name of event + * @param headers additional HTTP headers to send + * @param callback {@link ResponseCallback} to handle response or exception + */ + void getEventSchemaByEventName( + String eventName, String payloadFormat, Map<String, List<String>> headers, ResponseCallback callback); + + /** + * + * @param schemaId Id of Schema + * @param headers additional HTTP headers to send + * @param callback {@link ResponseCallback} to handle response or exception + */ + void getEventSchemaBySchemaId( + String schemaId, String payloadFormat, Map<String, List<String>> headers, ResponseCallback callback); } diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/dto/EventSchemaFormatEnum.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/dto/EventSchemaFormatEnum.java new file mode 100644 index 00000000000..4f889256dcb --- /dev/null +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/dto/EventSchemaFormatEnum.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.salesforce.internal.dto; + +public enum EventSchemaFormatEnum { + + // Apache Avro format but doesn't strictly adhere to the record complex type. + EXPANDED("EXPANDED"), + // Adheres to the Apache Avro specification for the record complex type + COMPACT("COMPACT"); + + final String value; + + EventSchemaFormatEnum(String value) { + this.value = value; + } + + public String value() { + return this.value; + } + + public static EventSchemaFormatEnum fromValue(String value) { + for (EventSchemaFormatEnum e : EventSchemaFormatEnum.values()) { + if (e.value.equals(value)) { + return e; + } + } + throw new IllegalArgumentException(value); + } +} diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java index cecd9fd630f..724386879a2 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java @@ -45,11 +45,14 @@ import org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest; import org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequests; import org.apache.camel.component.salesforce.internal.client.RestClient; import org.apache.camel.component.salesforce.internal.client.RestClient.ResponseCallback; +import org.apache.camel.component.salesforce.internal.dto.EventSchemaFormatEnum; import org.apache.camel.support.service.ServiceHelper; import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.APEX_METHOD; import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.APEX_QUERY_PARAM_PREFIX; import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.APEX_URL; +import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.EVENT_NAME; +import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.EVENT_SCHEMA_ID; import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.SOBJECT_BLOB_FIELD_NAME; import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME; import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE; @@ -192,6 +195,9 @@ public abstract class AbstractRestProcessor extends AbstractSalesforceProcessor case APPROVALS: processApprovals(exchange, callback); break; + case GET_EVENT_SCHEMA: + processGetEventSchema(exchange, callback); + break; default: throw new SalesforceException("Unknown operation name: " + operationName.value(), null); } @@ -212,6 +218,26 @@ public abstract class AbstractRestProcessor extends AbstractSalesforceProcessor return false; } + private void processGetEventSchema(Exchange exchange, AsyncCallback callback) throws SalesforceException { + endpointConfigMap.get(SalesforceEndpointConfig.API_VERSION); + final String eventName = getParameter(EVENT_NAME, exchange, IGNORE_BODY, IS_OPTIONAL); + final String schemaId = getParameter(EVENT_SCHEMA_ID, exchange, IGNORE_BODY, IS_OPTIONAL); + final EventSchemaFormatEnum eventSchemaFormat + = getParameter(SalesforceEndpointConfig.EVENT_SCHEMA_FORMAT, exchange, IGNORE_BODY, + IS_OPTIONAL, EventSchemaFormatEnum.class); + final String payloadFormat + = eventSchemaFormat != null ? eventSchemaFormat.value() : EventSchemaFormatEnum.EXPANDED.value(); + if (eventName != null) { + restClient.getEventSchemaByEventName(eventName, payloadFormat, determineHeaders(exchange), + processWithResponseCallback(exchange, callback)); + } else if (schemaId != null) { + restClient.getEventSchemaBySchemaId(schemaId, payloadFormat, determineHeaders(exchange), + processWithResponseCallback(exchange, callback)); + } else { + throw new SalesforceException("Either " + EVENT_NAME + " or " + EVENT_SCHEMA_ID + " is required.", 0); + } + } + final void processApproval(final Exchange exchange, final AsyncCallback callback) throws SalesforceException { final TypeConverter converter = exchange.getContext().getTypeConverter(); diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/SalesforceProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/SalesforceProcessor.java index d3e3533c13e..c1bc35716fa 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/SalesforceProcessor.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/SalesforceProcessor.java @@ -57,8 +57,6 @@ public interface SalesforceProcessor extends Service { } } } - return answer; } - } diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/RestApiIntegrationTest.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/RestApiIntegrationTest.java index 1ef44f6d2f6..e8fa5e95704 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/RestApiIntegrationTest.java +++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/RestApiIntegrationTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.salesforce; +import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.time.ZoneId; @@ -74,6 +75,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.EVENT_NAME; +import static org.apache.camel.component.salesforce.SalesforceEndpointConfig.EVENT_SCHEMA_ID; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -526,6 +529,35 @@ public class RestApiIntegrationTest extends AbstractSalesforceTestBase { assertNotNull(versions); } + @Test + public void testGetEventSchemaByEventName() { + final Object expandedResult + = template.requestBodyAndHeader("salesforce:getEventSchema", "", EVENT_NAME, "BatchApexErrorEvent"); + assertNotNull(expandedResult); + + final Object compactResult = template.requestBodyAndHeaders("salesforce:getEventSchema", "", + Map.of(EVENT_NAME, "BatchApexErrorEvent", + SalesforceEndpointConfig.EVENT_SCHEMA_FORMAT, "compact")); + assertNotNull(compactResult); + } + + @Test + public void testGetEventSchemaBySchemaId() throws IOException { + final Object schemaResult = template.requestBodyAndHeaders("salesforce:getEventSchema", "", + Map.of(EVENT_NAME, "BatchApexErrorEvent", + SalesforceEndpointConfig.EVENT_SCHEMA_FORMAT, "compact")); + assertNotNull(schemaResult); + + ObjectMapper mapper = new ObjectMapper(); + @SuppressWarnings("unchecked") + final Map<String, Object> map = (Map<String, Object>) mapper.readValue((InputStream) schemaResult, Map.class); + final String schemaId = (String) map.get("uuid"); + + final Object idResult = template.requestBodyAndHeader("salesforce:getEventSchema", "", EVENT_SCHEMA_ID, schemaId); + System.out.println(idResult); + assertNotNull(idResult); + } + @Test public void testQuery() throws Exception { createLineItem();