Skip to content

Commit

Permalink
Automated SDK update
Browse files Browse the repository at this point in the history
This updates the SDK from internal repo commit segmentio/public-api@7b03d4b7.
  • Loading branch information
APIs and Common Services team committed Jan 13, 2025
1 parent c27a047 commit b1b969f
Show file tree
Hide file tree
Showing 10 changed files with 430 additions and 23 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -28,7 +28,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.segment.publicapi</groupId>
<artifactId>segment-publicapi</artifactId>
<version>57.2.0</version>
<version>57.3.0</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -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"
}
```

Expand All @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>segment-publicapi</artifactId>
<packaging>jar</packaging>
<name>segment-publicapi</name>
<version>57.2.0</version>
<version>57.3.0</version>
<url>https://segment.com/docs/api/public-api/</url>
<description>Segment Public API</description>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/segment/publicapi/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Authentication>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/segment/publicapi/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/segment/publicapi/JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
89 changes: 83 additions & 6 deletions src/main/java/com/segment/publicapi/models/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
final TypeAdapter<ReverseEtlCronScheduleConfig> adapterReverseEtlCronScheduleConfig =
gson.getDelegateAdapter(
this, TypeToken.get(ReverseEtlCronScheduleConfig.class));
final TypeAdapter<ReverseEtlDbtCloudScheduleConfig>
adapterReverseEtlDbtCloudScheduleConfig =
gson.getDelegateAdapter(
this, TypeToken.get(ReverseEtlDbtCloudScheduleConfig.class));

return (TypeAdapter<T>)
new TypeAdapter<Config>() {
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand All @@ -211,6 +254,7 @@ public Config(ReverseEtlSpecificTimeScheduleConfig o) {
schemas.put(
"ReverseEtlSpecificTimeScheduleConfig", ReverseEtlSpecificTimeScheduleConfig.class);
schemas.put("ReverseEtlCronScheduleConfig", ReverseEtlCronScheduleConfig.class);
schemas.put("ReverseEtlDbtCloudScheduleConfig", ReverseEtlDbtCloudScheduleConfig.class);
}

@Override
Expand All @@ -221,7 +265,8 @@ public Map<String, Class<?>> 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
*
* <p>It could be an instance of the 'anyOf' schemas.
*/
Expand All @@ -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() {
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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
*/
Expand Down
Loading

0 comments on commit b1b969f

Please sign in to comment.