diff --git a/README.md b/README.md index da6f8457..8e0c1bfa 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ All endpoints in the API follow REST conventions and use standard HTTP methods. See the next sections for more information on how to use the Segment Public API Java SDK. -Latest API and SDK version: 57.2.0 +Latest API and SDK version: 57.3.0 ## Requirements @@ -28,7 +28,7 @@ Add this dependency to your project's POM: com.segment.publicapi segment-publicapi - 57.2.0 + 57.3.0 compile ``` @@ -44,7 +44,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "com.segment.publicapi:segment-publicapi:57.2.0" + implementation "com.segment.publicapi:segment-publicapi:57.3.0" } ``` @@ -58,7 +58,7 @@ mvn clean package Then manually install the following JARs: -* `target/segment-publicapi-57.2.0.jar` +* `target/segment-publicapi-57.3.0.jar` * `target/lib/*.jar` You are now ready to start making calls to Public API! diff --git a/pom.xml b/pom.xml index 7495a21d..79ce76a7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ segment-publicapi jar segment-publicapi - 57.2.0 + 57.3.0 https://segment.com/docs/api/public-api/ Segment Public API diff --git a/src/main/java/com/segment/publicapi/ApiClient.java b/src/main/java/com/segment/publicapi/ApiClient.java index f40f1146..6fbf3881 100644 --- a/src/main/java/com/segment/publicapi/ApiClient.java +++ b/src/main/java/com/segment/publicapi/ApiClient.java @@ -123,7 +123,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("Public API SDK 57.2.0 (Java)"); + setUserAgent("Public API SDK 57.3.0 (Java)"); authentications = new HashMap(); } diff --git a/src/main/java/com/segment/publicapi/Configuration.java b/src/main/java/com/segment/publicapi/Configuration.java index df2f582b..5048cb9a 100644 --- a/src/main/java/com/segment/publicapi/Configuration.java +++ b/src/main/java/com/segment/publicapi/Configuration.java @@ -12,7 +12,7 @@ package com.segment.publicapi; public class Configuration { - public static final String VERSION = "57.2.0"; + public static final String VERSION = "57.3.0"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/segment/publicapi/JSON.java b/src/main/java/com/segment/publicapi/JSON.java index 20c61990..9d283993 100644 --- a/src/main/java/com/segment/publicapi/JSON.java +++ b/src/main/java/com/segment/publicapi/JSON.java @@ -1345,6 +1345,9 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new com.segment.publicapi.models.ReverseEtlCronScheduleConfig .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.segment.publicapi.models.ReverseEtlDbtCloudScheduleConfig + .CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new com.segment.publicapi.models.ReverseEtlModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( diff --git a/src/main/java/com/segment/publicapi/models/Config.java b/src/main/java/com/segment/publicapi/models/Config.java index fed0fbe5..a1455431 100644 --- a/src/main/java/com/segment/publicapi/models/Config.java +++ b/src/main/java/com/segment/publicapi/models/Config.java @@ -49,6 +49,10 @@ public TypeAdapter create(Gson gson, TypeToken type) { final TypeAdapter adapterReverseEtlCronScheduleConfig = gson.getDelegateAdapter( this, TypeToken.get(ReverseEtlCronScheduleConfig.class)); + final TypeAdapter + adapterReverseEtlDbtCloudScheduleConfig = + gson.getDelegateAdapter( + this, TypeToken.get(ReverseEtlDbtCloudScheduleConfig.class)); return (TypeAdapter) new TypeAdapter() { @@ -91,9 +95,21 @@ public void write(JsonWriter out, Config value) throws IOException { elementAdapter.write(out, element); return; } + // check if the actual instance is of the type + // `ReverseEtlDbtCloudScheduleConfig` + if (value.getActualInstance() + instanceof ReverseEtlDbtCloudScheduleConfig) { + JsonElement element = + adapterReverseEtlDbtCloudScheduleConfig.toJsonTree( + (ReverseEtlDbtCloudScheduleConfig) + value.getActualInstance()); + elementAdapter.write(out, element); + return; + } throw new IOException( "Failed to serialize as the type doesn't match anyOf schemae:" + " ReverseEtlCronScheduleConfig," + + " ReverseEtlDbtCloudScheduleConfig," + " ReverseEtlPeriodicScheduleConfig," + " ReverseEtlSpecificTimeScheduleConfig"); } @@ -172,6 +188,28 @@ public Config read(JsonReader in) throws IOException { + " 'ReverseEtlCronScheduleConfig'", e); } + // deserialize ReverseEtlDbtCloudScheduleConfig + try { + // validate the JSON object to see if any exception is thrown + ReverseEtlDbtCloudScheduleConfig.validateJsonElement(jsonElement); + actualAdapter = adapterReverseEtlDbtCloudScheduleConfig; + Config ret = new Config(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + "Deserialization for" + + " ReverseEtlDbtCloudScheduleConfig failed" + + " with `%s`.", + e.getMessage())); + log.log( + Level.FINER, + "Input data does not match schema" + + " 'ReverseEtlDbtCloudScheduleConfig'", + e); + } throw new IOException( String.format( @@ -196,6 +234,11 @@ public Config(ReverseEtlCronScheduleConfig o) { setActualInstance(o); } + public Config(ReverseEtlDbtCloudScheduleConfig o) { + super("anyOf", Boolean.TRUE); + setActualInstance(o); + } + public Config(ReverseEtlPeriodicScheduleConfig o) { super("anyOf", Boolean.TRUE); setActualInstance(o); @@ -211,6 +254,7 @@ public Config(ReverseEtlSpecificTimeScheduleConfig o) { schemas.put( "ReverseEtlSpecificTimeScheduleConfig", ReverseEtlSpecificTimeScheduleConfig.class); schemas.put("ReverseEtlCronScheduleConfig", ReverseEtlCronScheduleConfig.class); + schemas.put("ReverseEtlDbtCloudScheduleConfig", ReverseEtlDbtCloudScheduleConfig.class); } @Override @@ -221,7 +265,8 @@ public Map> getSchemas() { /** * Set the instance that matches the anyOf child schema, check the instance parameter is valid * against the anyOf child schemas: ReverseEtlCronScheduleConfig, - * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig + * ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig, + * ReverseEtlSpecificTimeScheduleConfig * *

It could be an instance of the 'anyOf' schemas. */ @@ -247,17 +292,24 @@ public void setActualInstance(Object instance) { return; } + if (instance instanceof ReverseEtlDbtCloudScheduleConfig) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( "Invalid instance type. Must be ReverseEtlCronScheduleConfig," - + " ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig"); + + " ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig," + + " ReverseEtlSpecificTimeScheduleConfig"); } /** * Get the actual instance, which can be the following: ReverseEtlCronScheduleConfig, - * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig + * ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig, + * ReverseEtlSpecificTimeScheduleConfig * - * @return The actual instance (ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig, - * ReverseEtlSpecificTimeScheduleConfig) + * @return The actual instance (ReverseEtlCronScheduleConfig, ReverseEtlDbtCloudScheduleConfig, + * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig) */ @Override public Object getActualInstance() { @@ -300,6 +352,18 @@ public ReverseEtlCronScheduleConfig getReverseEtlCronScheduleConfig() return (ReverseEtlCronScheduleConfig) super.getActualInstance(); } + /** + * Get the actual instance of `ReverseEtlDbtCloudScheduleConfig`. If the actual instance is not + * `ReverseEtlDbtCloudScheduleConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `ReverseEtlDbtCloudScheduleConfig` + * @throws ClassCastException if the instance is not `ReverseEtlDbtCloudScheduleConfig` + */ + public ReverseEtlDbtCloudScheduleConfig getReverseEtlDbtCloudScheduleConfig() + throws ClassCastException { + return (ReverseEtlDbtCloudScheduleConfig) super.getActualInstance(); + } + /** * Validates the JSON Element and throws an exception if issues found * @@ -344,10 +408,23 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti e.getMessage())); // continue to the next one } + // validate the json string with ReverseEtlDbtCloudScheduleConfig + try { + ReverseEtlDbtCloudScheduleConfig.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add( + String.format( + "Deserialization for ReverseEtlDbtCloudScheduleConfig failed with" + + " `%s`.", + e.getMessage())); + // continue to the next one + } throw new IOException( String.format( "The JSON string is invalid for Config with anyOf schemas:" - + " ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig," + + " ReverseEtlCronScheduleConfig, ReverseEtlDbtCloudScheduleConfig," + + " ReverseEtlPeriodicScheduleConfig," + " ReverseEtlSpecificTimeScheduleConfig. no class match the result," + " expected at least 1. Detailed failure message for anyOf schemas:" + " %s. JSON: %s", diff --git a/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java b/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java index 8d8555e5..78d96c4b 100644 --- a/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java +++ b/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java @@ -27,7 +27,7 @@ import java.util.Objects; import java.util.Set; -/** Defines the DBT Model Sync Trigger. */ +/** Defines the dbt Model Sync Trigger. */ public class DbtModelSyncTrigger { public static final String SERIALIZED_NAME_ID = "id"; @@ -53,7 +53,7 @@ public DbtModelSyncTrigger id(String id) { } /** - * The id of the DBT Model Sync. + * The id of the dbt model sync. * * @return id */ diff --git a/src/main/java/com/segment/publicapi/models/ReverseEtlDbtCloudScheduleConfig.java b/src/main/java/com/segment/publicapi/models/ReverseEtlDbtCloudScheduleConfig.java new file mode 100644 index 00000000..493daba2 --- /dev/null +++ b/src/main/java/com/segment/publicapi/models/ReverseEtlDbtCloudScheduleConfig.java @@ -0,0 +1,249 @@ +/* + * Segment Public API + * The Segment Public API helps you manage your Segment Workspaces and its resources. You can use the API to perform CRUD (create, read, update, delete) operations at no extra charge. This includes working with resources such as Sources, Destinations, Warehouses, Tracking Plans, and the Segment Destinations and Sources Catalogs. All CRUD endpoints in the API follow REST conventions and use standard HTTP methods. Different URL endpoints represent different resources in a Workspace. See the next sections for more information on how to use the Segment Public API. + * + * Contact: friends@segment.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.segment.publicapi.models; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.segment.publicapi.JSON; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Definition for a schedule triggered by dbt Cloud job events. */ +public class ReverseEtlDbtCloudScheduleConfig { + public static final String SERIALIZED_NAME_JOB_ID = "jobId"; + + @SerializedName(SERIALIZED_NAME_JOB_ID) + private String jobId; + + public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId"; + + @SerializedName(SERIALIZED_NAME_ACCOUNT_ID) + private String accountId; + + public ReverseEtlDbtCloudScheduleConfig() {} + + public ReverseEtlDbtCloudScheduleConfig jobId(String jobId) { + + this.jobId = jobId; + return this; + } + + /** + * The dbt Cloud job used to trigger a sync for a Reverse ETL Connection. + * + * @return jobId + */ + @javax.annotation.Nonnull + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public ReverseEtlDbtCloudScheduleConfig accountId(String accountId) { + + this.accountId = accountId; + return this; + } + + /** + * The dbt Cloud account where the job belongs to. + * + * @return accountId + */ + @javax.annotation.Nonnull + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReverseEtlDbtCloudScheduleConfig reverseEtlDbtCloudScheduleConfig = + (ReverseEtlDbtCloudScheduleConfig) o; + return Objects.equals(this.jobId, reverseEtlDbtCloudScheduleConfig.jobId) + && Objects.equals(this.accountId, reverseEtlDbtCloudScheduleConfig.accountId); + } + + @Override + public int hashCode() { + return Objects.hash(jobId, accountId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReverseEtlDbtCloudScheduleConfig {\n"); + sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n"); + sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("jobId"); + openapiFields.add("accountId"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("jobId"); + openapiRequiredFields.add("accountId"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * ReverseEtlDbtCloudScheduleConfig + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ReverseEtlDbtCloudScheduleConfig.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ReverseEtlDbtCloudScheduleConfig is" + + " not found in the empty JSON string", + ReverseEtlDbtCloudScheduleConfig.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ReverseEtlDbtCloudScheduleConfig.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `ReverseEtlDbtCloudScheduleConfig` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ReverseEtlDbtCloudScheduleConfig.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("jobId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `jobId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("jobId").toString())); + } + if (!jsonObj.get("accountId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `accountId` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("accountId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ReverseEtlDbtCloudScheduleConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ReverseEtlDbtCloudScheduleConfig' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(ReverseEtlDbtCloudScheduleConfig.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ReverseEtlDbtCloudScheduleConfig value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ReverseEtlDbtCloudScheduleConfig read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ReverseEtlDbtCloudScheduleConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of ReverseEtlDbtCloudScheduleConfig + * @throws IOException if the JSON string is invalid with respect to + * ReverseEtlDbtCloudScheduleConfig + */ + public static ReverseEtlDbtCloudScheduleConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ReverseEtlDbtCloudScheduleConfig.class); + } + + /** + * Convert an instance of ReverseEtlDbtCloudScheduleConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleConfig.java b/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleConfig.java index 47909984..62a91020 100644 --- a/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleConfig.java +++ b/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleConfig.java @@ -50,6 +50,10 @@ public TypeAdapter create(Gson gson, TypeToken type) { final TypeAdapter adapterReverseEtlCronScheduleConfig = gson.getDelegateAdapter( this, TypeToken.get(ReverseEtlCronScheduleConfig.class)); + final TypeAdapter + adapterReverseEtlDbtCloudScheduleConfig = + gson.getDelegateAdapter( + this, TypeToken.get(ReverseEtlDbtCloudScheduleConfig.class)); return (TypeAdapter) new TypeAdapter() { @@ -93,9 +97,21 @@ public void write(JsonWriter out, ReverseEtlScheduleConfig value) elementAdapter.write(out, element); return; } + // check if the actual instance is of the type + // `ReverseEtlDbtCloudScheduleConfig` + if (value.getActualInstance() + instanceof ReverseEtlDbtCloudScheduleConfig) { + JsonElement element = + adapterReverseEtlDbtCloudScheduleConfig.toJsonTree( + (ReverseEtlDbtCloudScheduleConfig) + value.getActualInstance()); + elementAdapter.write(out, element); + return; + } throw new IOException( "Failed to serialize as the type doesn't match anyOf schemae:" + " ReverseEtlCronScheduleConfig," + + " ReverseEtlDbtCloudScheduleConfig," + " ReverseEtlPeriodicScheduleConfig," + " ReverseEtlSpecificTimeScheduleConfig"); } @@ -174,6 +190,28 @@ public ReverseEtlScheduleConfig read(JsonReader in) throws IOException { + " 'ReverseEtlCronScheduleConfig'", e); } + // deserialize ReverseEtlDbtCloudScheduleConfig + try { + // validate the JSON object to see if any exception is thrown + ReverseEtlDbtCloudScheduleConfig.validateJsonElement(jsonElement); + actualAdapter = adapterReverseEtlDbtCloudScheduleConfig; + ReverseEtlScheduleConfig ret = new ReverseEtlScheduleConfig(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + "Deserialization for" + + " ReverseEtlDbtCloudScheduleConfig failed" + + " with `%s`.", + e.getMessage())); + log.log( + Level.FINER, + "Input data does not match schema" + + " 'ReverseEtlDbtCloudScheduleConfig'", + e); + } throw new IOException( String.format( @@ -199,6 +237,11 @@ public ReverseEtlScheduleConfig(ReverseEtlCronScheduleConfig o) { setActualInstance(o); } + public ReverseEtlScheduleConfig(ReverseEtlDbtCloudScheduleConfig o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + public ReverseEtlScheduleConfig(ReverseEtlPeriodicScheduleConfig o) { super("anyOf", Boolean.FALSE); setActualInstance(o); @@ -214,6 +257,7 @@ public ReverseEtlScheduleConfig(ReverseEtlSpecificTimeScheduleConfig o) { schemas.put( "ReverseEtlSpecificTimeScheduleConfig", ReverseEtlSpecificTimeScheduleConfig.class); schemas.put("ReverseEtlCronScheduleConfig", ReverseEtlCronScheduleConfig.class); + schemas.put("ReverseEtlDbtCloudScheduleConfig", ReverseEtlDbtCloudScheduleConfig.class); } @Override @@ -224,7 +268,8 @@ public Map> getSchemas() { /** * Set the instance that matches the anyOf child schema, check the instance parameter is valid * against the anyOf child schemas: ReverseEtlCronScheduleConfig, - * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig + * ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig, + * ReverseEtlSpecificTimeScheduleConfig * *

It could be an instance of the 'anyOf' schemas. */ @@ -245,17 +290,24 @@ public void setActualInstance(Object instance) { return; } + if (instance instanceof ReverseEtlDbtCloudScheduleConfig) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( "Invalid instance type. Must be ReverseEtlCronScheduleConfig," - + " ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig"); + + " ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig," + + " ReverseEtlSpecificTimeScheduleConfig"); } /** * Get the actual instance, which can be the following: ReverseEtlCronScheduleConfig, - * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig + * ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig, + * ReverseEtlSpecificTimeScheduleConfig * - * @return The actual instance (ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig, - * ReverseEtlSpecificTimeScheduleConfig) + * @return The actual instance (ReverseEtlCronScheduleConfig, ReverseEtlDbtCloudScheduleConfig, + * ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig) */ @Override public Object getActualInstance() { @@ -298,6 +350,18 @@ public ReverseEtlCronScheduleConfig getReverseEtlCronScheduleConfig() return (ReverseEtlCronScheduleConfig) super.getActualInstance(); } + /** + * Get the actual instance of `ReverseEtlDbtCloudScheduleConfig`. If the actual instance is not + * `ReverseEtlDbtCloudScheduleConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `ReverseEtlDbtCloudScheduleConfig` + * @throws ClassCastException if the instance is not `ReverseEtlDbtCloudScheduleConfig` + */ + public ReverseEtlDbtCloudScheduleConfig getReverseEtlDbtCloudScheduleConfig() + throws ClassCastException { + return (ReverseEtlDbtCloudScheduleConfig) super.getActualInstance(); + } + /** * Validates the JSON Element and throws an exception if issues found * @@ -342,11 +406,23 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti e.getMessage())); // continue to the next one } + // validate the json string with ReverseEtlDbtCloudScheduleConfig + try { + ReverseEtlDbtCloudScheduleConfig.validateJsonElement(jsonElement); + return; + } catch (Exception e) { + errorMessages.add( + String.format( + "Deserialization for ReverseEtlDbtCloudScheduleConfig failed with" + + " `%s`.", + e.getMessage())); + // continue to the next one + } throw new IOException( String.format( "The JSON string is invalid for ReverseEtlScheduleConfig with anyOf" + " schemas: ReverseEtlCronScheduleConfig," - + " ReverseEtlPeriodicScheduleConfig," + + " ReverseEtlDbtCloudScheduleConfig, ReverseEtlPeriodicScheduleConfig," + " ReverseEtlSpecificTimeScheduleConfig. no class match the result," + " expected at least 1. Detailed failure message for anyOf schemas:" + " %s. JSON: %s", diff --git a/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleDefinition.java b/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleDefinition.java index ba4eae98..9b466492 100644 --- a/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleDefinition.java +++ b/src/main/java/com/segment/publicapi/models/ReverseEtlScheduleDefinition.java @@ -35,11 +35,13 @@ * strategy. */ public class ReverseEtlScheduleDefinition { - /** Strategy supports: Periodic, Specific Days, Manual, CRON. */ + /** Strategy supports: Periodic, Specific Days, Manual, CRON and DBT_CLOUD. */ @JsonAdapter(StrategyEnum.Adapter.class) public enum StrategyEnum { CRON("CRON"), + DBT_CLOUD("DBT_CLOUD"), + MANUAL("MANUAL"), PERIODIC("PERIODIC"), @@ -104,7 +106,7 @@ public ReverseEtlScheduleDefinition strategy(StrategyEnum strategy) { } /** - * Strategy supports: Periodic, Specific Days, Manual, CRON. + * Strategy supports: Periodic, Specific Days, Manual, CRON and DBT_CLOUD. * * @return strategy */