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@e36063e2.
  • Loading branch information
APIs and Common Services team committed Oct 1, 2024
1 parent 948bf9c commit 4be8aec
Show file tree
Hide file tree
Showing 9 changed files with 490 additions and 31 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: 54.2.0
Latest API and SDK version: 54.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>54.2.0</version>
<version>54.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:54.2.0"
implementation "com.segment.publicapi:segment-publicapi:54.3.0"
}
```

Expand All @@ -58,7 +58,7 @@ mvn clean package

Then manually install the following JARs:

* `target/segment-publicapi-54.2.0.jar`
* `target/segment-publicapi-54.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>54.2.0</version>
<version>54.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 54.2.0 (Java)");
setUserAgent("Public API SDK 54.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 = "54.2.0";
public static final String VERSION = "54.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 @@ -1322,6 +1322,9 @@ private static Class getClassByDiscriminator(
.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
new com.segment.publicapi.models.ReverseETLSyncStatus.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
new com.segment.publicapi.models.ReverseEtlCronScheduleConfig
.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
new com.segment.publicapi.models.ReverseEtlModel.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
Expand Down
85 changes: 77 additions & 8 deletions src/main/java/com/segment/publicapi/models/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
gson.getDelegateAdapter(
this,
TypeToken.get(ReverseEtlSpecificTimeScheduleConfig.class));
final TypeAdapter<ReverseEtlCronScheduleConfig> adapterReverseEtlCronScheduleConfig =
gson.getDelegateAdapter(
this, TypeToken.get(ReverseEtlCronScheduleConfig.class));

return (TypeAdapter<T>)
new TypeAdapter<Config>() {
Expand Down Expand Up @@ -78,8 +81,19 @@ public void write(JsonWriter out, Config value) throws IOException {
elementAdapter.write(out, element);
return;
}
// check if the actual instance is of the type
// `ReverseEtlCronScheduleConfig`
if (value.getActualInstance() instanceof ReverseEtlCronScheduleConfig) {
JsonElement element =
adapterReverseEtlCronScheduleConfig.toJsonTree(
(ReverseEtlCronScheduleConfig)
value.getActualInstance());
elementAdapter.write(out, element);
return;
}
throw new IOException(
"Failed to serialize as the type doesn't match anyOf schemae:"
+ " ReverseEtlCronScheduleConfig,"
+ " ReverseEtlPeriodicScheduleConfig,"
+ " ReverseEtlSpecificTimeScheduleConfig");
}
Expand Down Expand Up @@ -137,6 +151,27 @@ public Config read(JsonReader in) throws IOException {
+ " 'ReverseEtlSpecificTimeScheduleConfig'",
e);
}
// deserialize ReverseEtlCronScheduleConfig
try {
// validate the JSON object to see if any exception is thrown
ReverseEtlCronScheduleConfig.validateJsonElement(jsonElement);
actualAdapter = adapterReverseEtlCronScheduleConfig;
Config ret = new Config();
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
return ret;
} catch (Exception e) {
// deserialization failed, continue
errorMessages.add(
String.format(
"Deserialization for ReverseEtlCronScheduleConfig"
+ " failed with `%s`.",
e.getMessage()));
log.log(
Level.FINER,
"Input data does not match schema"
+ " 'ReverseEtlCronScheduleConfig'",
e);
}

throw new IOException(
String.format(
Expand All @@ -156,6 +191,11 @@ public Config() {
super("anyOf", Boolean.TRUE);
}

public Config(ReverseEtlCronScheduleConfig o) {
super("anyOf", Boolean.TRUE);
setActualInstance(o);
}

public Config(ReverseEtlPeriodicScheduleConfig o) {
super("anyOf", Boolean.TRUE);
setActualInstance(o);
Expand All @@ -170,6 +210,7 @@ public Config(ReverseEtlSpecificTimeScheduleConfig o) {
schemas.put("ReverseEtlPeriodicScheduleConfig", ReverseEtlPeriodicScheduleConfig.class);
schemas.put(
"ReverseEtlSpecificTimeScheduleConfig", ReverseEtlSpecificTimeScheduleConfig.class);
schemas.put("ReverseEtlCronScheduleConfig", ReverseEtlCronScheduleConfig.class);
}

@Override
Expand All @@ -179,8 +220,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: ReverseEtlPeriodicScheduleConfig,
* ReverseEtlSpecificTimeScheduleConfig
* against the anyOf child schemas: ReverseEtlCronScheduleConfig,
* ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig
*
* <p>It could be an instance of the 'anyOf' schemas.
*/
Expand All @@ -201,16 +242,21 @@ public void setActualInstance(Object instance) {
return;
}

if (instance instanceof ReverseEtlCronScheduleConfig) {
super.setActualInstance(instance);
return;
}

throw new RuntimeException(
"Invalid instance type. Must be ReverseEtlPeriodicScheduleConfig,"
+ " ReverseEtlSpecificTimeScheduleConfig");
"Invalid instance type. Must be ReverseEtlCronScheduleConfig,"
+ " ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig");
}

/**
* Get the actual instance, which can be the following: ReverseEtlPeriodicScheduleConfig,
* ReverseEtlSpecificTimeScheduleConfig
* Get the actual instance, which can be the following: ReverseEtlCronScheduleConfig,
* ReverseEtlPeriodicScheduleConfig, ReverseEtlSpecificTimeScheduleConfig
*
* @return The actual instance (ReverseEtlPeriodicScheduleConfig,
* @return The actual instance (ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig,
* ReverseEtlSpecificTimeScheduleConfig)
*/
@Override
Expand Down Expand Up @@ -242,6 +288,18 @@ public ReverseEtlSpecificTimeScheduleConfig getReverseEtlSpecificTimeScheduleCon
return (ReverseEtlSpecificTimeScheduleConfig) super.getActualInstance();
}

/**
* Get the actual instance of `ReverseEtlCronScheduleConfig`. If the actual instance is not
* `ReverseEtlCronScheduleConfig`, the ClassCastException will be thrown.
*
* @return The actual instance of `ReverseEtlCronScheduleConfig`
* @throws ClassCastException if the instance is not `ReverseEtlCronScheduleConfig`
*/
public ReverseEtlCronScheduleConfig getReverseEtlCronScheduleConfig()
throws ClassCastException {
return (ReverseEtlCronScheduleConfig) super.getActualInstance();
}

/**
* Validates the JSON Element and throws an exception if issues found
*
Expand Down Expand Up @@ -275,10 +333,21 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
e.getMessage()));
// continue to the next one
}
// validate the json string with ReverseEtlCronScheduleConfig
try {
ReverseEtlCronScheduleConfig.validateJsonElement(jsonElement);
return;
} catch (Exception e) {
errorMessages.add(
String.format(
"Deserialization for ReverseEtlCronScheduleConfig 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:"
+ " ReverseEtlPeriodicScheduleConfig,"
+ " ReverseEtlCronScheduleConfig, ReverseEtlPeriodicScheduleConfig,"
+ " ReverseEtlSpecificTimeScheduleConfig. no class match the result,"
+ " expected at least 1. Detailed failure message for anyOf schemas:"
+ " %s. JSON: %s",
Expand Down
Loading

0 comments on commit 4be8aec

Please sign in to comment.