Skip to content

Commit b5622a0

Browse files
author
APIs and Common Services team
committed
Automated SDK update
This updates the SDK from internal repo commit segmentio/public-api@2de0cfa8.
1 parent b318285 commit b5622a0

11 files changed

+1051
-134
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All endpoints in the API follow REST conventions and use standard HTTP methods.
1010

1111
See the next sections for more information on how to use the Segment Public API Java SDK.
1212

13-
Latest API and SDK version: 58.8.0
13+
Latest API and SDK version: 58.9.0
1414

1515
## Requirements
1616

@@ -28,7 +28,7 @@ Add this dependency to your project's POM:
2828
<dependency>
2929
<groupId>com.segment.publicapi</groupId>
3030
<artifactId>segment-publicapi</artifactId>
31-
<version>58.8.0</version>
31+
<version>58.9.0</version>
3232
<scope>compile</scope>
3333
</dependency>
3434
```
@@ -44,7 +44,7 @@ Add this dependency to your project's build file:
4444
}
4545
4646
dependencies {
47-
implementation "com.segment.publicapi:segment-publicapi:58.8.0"
47+
implementation "com.segment.publicapi:segment-publicapi:58.9.0"
4848
}
4949
```
5050

@@ -58,7 +58,7 @@ mvn clean package
5858

5959
Then manually install the following JARs:
6060

61-
* `target/segment-publicapi-58.8.0.jar`
61+
* `target/segment-publicapi-58.9.0.jar`
6262
* `target/lib/*.jar`
6363

6464
You are now ready to start making calls to Public API!

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>segment-publicapi</artifactId>
66
<packaging>jar</packaging>
77
<name>segment-publicapi</name>
8-
<version>58.8.0</version>
8+
<version>58.9.0</version>
99
<url>https://segment.com/docs/api/public-api/</url>
1010
<description>Segment Public API</description>
1111
<scm>

src/main/java/com/segment/publicapi/ApiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void init() {
123123
json = new JSON();
124124

125125
// Set default User-Agent.
126-
setUserAgent("Public API SDK 58.8.0 (Java)");
126+
setUserAgent("Public API SDK 58.9.0 (Java)");
127127

128128
authentications = new HashMap<String, Authentication>();
129129
}

src/main/java/com/segment/publicapi/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
package com.segment.publicapi;
1313

1414
public class Configuration {
15-
public static final String VERSION = "58.8.0";
15+
public static final String VERSION = "58.9.0";
1616

1717
private static ApiClient defaultApiClient = new ApiClient();
1818

src/main/java/com/segment/publicapi/JSON.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,15 @@ private static Class getClassByDiscriminator(
177177
.CustomTypeAdapterFactory());
178178
gsonBuilder.registerTypeAdapterFactory(
179179
new com.segment.publicapi.models.AudiencePreview.CustomTypeAdapterFactory());
180+
gsonBuilder.registerTypeAdapterFactory(
181+
new com.segment.publicapi.models.AudiencePreviewAccountResult
182+
.CustomTypeAdapterFactory());
180183
gsonBuilder.registerTypeAdapterFactory(
181184
new com.segment.publicapi.models.AudiencePreviewIdentifier
182185
.CustomTypeAdapterFactory());
186+
gsonBuilder.registerTypeAdapterFactory(
187+
new com.segment.publicapi.models.AudiencePreviewProfileResult
188+
.CustomTypeAdapterFactory());
183189
gsonBuilder.registerTypeAdapterFactory(
184190
new com.segment.publicapi.models.AudiencePreviewResult.CustomTypeAdapterFactory());
185191
gsonBuilder.registerTypeAdapterFactory(
@@ -647,6 +653,8 @@ private static Class getClassByDiscriminator(
647653
new com.segment.publicapi.models.EchoV1Output.CustomTypeAdapterFactory());
648654
gsonBuilder.registerTypeAdapterFactory(
649655
new com.segment.publicapi.models.EdgeFunctionsAlpha.CustomTypeAdapterFactory());
656+
gsonBuilder.registerTypeAdapterFactory(
657+
new com.segment.publicapi.models.EntityDetails.CustomTypeAdapterFactory());
650658
gsonBuilder.registerTypeAdapterFactory(
651659
new com.segment.publicapi.models.EventSourceV1.CustomTypeAdapterFactory());
652660
gsonBuilder.registerTypeAdapterFactory(

src/main/java/com/segment/publicapi/models/AudiencePreview.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class AudiencePreview {
4343
public enum AudienceTypeEnum {
4444
ACCOUNTS("ACCOUNTS"),
4545

46+
LINKED("LINKED"),
47+
4648
USERS("USERS");
4749

4850
private String value;
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/*
2+
* Segment Public API
3+
* 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.
4+
*
5+
* Contact: [email protected]
6+
*
7+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8+
* https://openapi-generator.tech
9+
* Do not edit the class manually.
10+
*/
11+
12+
package com.segment.publicapi.models;
13+
14+
import com.google.gson.Gson;
15+
import com.google.gson.JsonElement;
16+
import com.google.gson.JsonObject;
17+
import com.google.gson.TypeAdapter;
18+
import com.google.gson.TypeAdapterFactory;
19+
import com.google.gson.annotations.SerializedName;
20+
import com.google.gson.reflect.TypeToken;
21+
import com.google.gson.stream.JsonReader;
22+
import com.google.gson.stream.JsonWriter;
23+
import com.segment.publicapi.JSON;
24+
import java.io.IOException;
25+
import java.util.HashSet;
26+
import java.util.Map;
27+
import java.util.Objects;
28+
import java.util.Set;
29+
30+
/** Result membership object for an audience preview with &#x60;audienceType: ACCOUNTS&#x60;. */
31+
public class AudiencePreviewAccountResult {
32+
public static final String SERIALIZED_NAME_ID = "id";
33+
34+
@SerializedName(SERIALIZED_NAME_ID)
35+
private String id;
36+
37+
public AudiencePreviewAccountResult() {}
38+
39+
public AudiencePreviewAccountResult id(String id) {
40+
41+
this.id = id;
42+
return this;
43+
}
44+
45+
/**
46+
* Account id.
47+
*
48+
* @return id
49+
*/
50+
@javax.annotation.Nonnull
51+
public String getId() {
52+
return id;
53+
}
54+
55+
public void setId(String id) {
56+
this.id = id;
57+
}
58+
59+
@Override
60+
public boolean equals(Object o) {
61+
if (this == o) {
62+
return true;
63+
}
64+
if (o == null || getClass() != o.getClass()) {
65+
return false;
66+
}
67+
AudiencePreviewAccountResult audiencePreviewAccountResult =
68+
(AudiencePreviewAccountResult) o;
69+
return Objects.equals(this.id, audiencePreviewAccountResult.id);
70+
}
71+
72+
@Override
73+
public int hashCode() {
74+
return Objects.hash(id);
75+
}
76+
77+
@Override
78+
public String toString() {
79+
StringBuilder sb = new StringBuilder();
80+
sb.append("class AudiencePreviewAccountResult {\n");
81+
sb.append(" id: ").append(toIndentedString(id)).append("\n");
82+
sb.append("}");
83+
return sb.toString();
84+
}
85+
86+
/**
87+
* Convert the given object to string with each line indented by 4 spaces (except the first
88+
* line).
89+
*/
90+
private String toIndentedString(Object o) {
91+
if (o == null) {
92+
return "null";
93+
}
94+
return o.toString().replace("\n", "\n ");
95+
}
96+
97+
public static HashSet<String> openapiFields;
98+
public static HashSet<String> openapiRequiredFields;
99+
100+
static {
101+
// a set of all properties/fields (JSON key names)
102+
openapiFields = new HashSet<String>();
103+
openapiFields.add("id");
104+
105+
// a set of required properties/fields (JSON key names)
106+
openapiRequiredFields = new HashSet<String>();
107+
openapiRequiredFields.add("id");
108+
}
109+
110+
/**
111+
* Validates the JSON Element and throws an exception if issues found
112+
*
113+
* @param jsonElement JSON Element
114+
* @throws IOException if the JSON Element is invalid with respect to
115+
* AudiencePreviewAccountResult
116+
*/
117+
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
118+
if (jsonElement == null) {
119+
if (!AudiencePreviewAccountResult.openapiRequiredFields
120+
.isEmpty()) { // has required fields but JSON element is null
121+
throw new IllegalArgumentException(
122+
String.format(
123+
"The required field(s) %s in AudiencePreviewAccountResult is not"
124+
+ " found in the empty JSON string",
125+
AudiencePreviewAccountResult.openapiRequiredFields.toString()));
126+
}
127+
}
128+
129+
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
130+
// check to see if the JSON string contains additional fields
131+
for (Map.Entry<String, JsonElement> entry : entries) {
132+
if (!AudiencePreviewAccountResult.openapiFields.contains(entry.getKey())) {
133+
throw new IllegalArgumentException(
134+
String.format(
135+
"The field `%s` in the JSON string is not defined in the"
136+
+ " `AudiencePreviewAccountResult` properties. JSON: %s",
137+
entry.getKey(), jsonElement.toString()));
138+
}
139+
}
140+
141+
// check to make sure all required properties/fields are present in the JSON string
142+
for (String requiredField : AudiencePreviewAccountResult.openapiRequiredFields) {
143+
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
144+
throw new IllegalArgumentException(
145+
String.format(
146+
"The required field `%s` is not found in the JSON string: %s",
147+
requiredField, jsonElement.toString()));
148+
}
149+
}
150+
JsonObject jsonObj = jsonElement.getAsJsonObject();
151+
if (!jsonObj.get("id").isJsonPrimitive()) {
152+
throw new IllegalArgumentException(
153+
String.format(
154+
"Expected the field `id` to be a primitive type in the JSON string but"
155+
+ " got `%s`",
156+
jsonObj.get("id").toString()));
157+
}
158+
}
159+
160+
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
161+
@SuppressWarnings("unchecked")
162+
@Override
163+
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
164+
if (!AudiencePreviewAccountResult.class.isAssignableFrom(type.getRawType())) {
165+
return null; // this class only serializes 'AudiencePreviewAccountResult' and its
166+
// subtypes
167+
}
168+
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
169+
final TypeAdapter<AudiencePreviewAccountResult> thisAdapter =
170+
gson.getDelegateAdapter(
171+
this, TypeToken.get(AudiencePreviewAccountResult.class));
172+
173+
return (TypeAdapter<T>)
174+
new TypeAdapter<AudiencePreviewAccountResult>() {
175+
@Override
176+
public void write(JsonWriter out, AudiencePreviewAccountResult value)
177+
throws IOException {
178+
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
179+
elementAdapter.write(out, obj);
180+
}
181+
182+
@Override
183+
public AudiencePreviewAccountResult read(JsonReader in) throws IOException {
184+
JsonElement jsonElement = elementAdapter.read(in);
185+
validateJsonElement(jsonElement);
186+
return thisAdapter.fromJsonTree(jsonElement);
187+
}
188+
}.nullSafe();
189+
}
190+
}
191+
192+
/**
193+
* Create an instance of AudiencePreviewAccountResult given an JSON string
194+
*
195+
* @param jsonString JSON string
196+
* @return An instance of AudiencePreviewAccountResult
197+
* @throws IOException if the JSON string is invalid with respect to
198+
* AudiencePreviewAccountResult
199+
*/
200+
public static AudiencePreviewAccountResult fromJson(String jsonString) throws IOException {
201+
return JSON.getGson().fromJson(jsonString, AudiencePreviewAccountResult.class);
202+
}
203+
204+
/**
205+
* Convert an instance of AudiencePreviewAccountResult to an JSON string
206+
*
207+
* @return JSON string
208+
*/
209+
public String toJson() {
210+
return JSON.getGson().toJson(this);
211+
}
212+
}

0 commit comments

Comments
 (0)