Skip to content

Commit 073fe07

Browse files
author
APIs and Common Services team
committed
Automated SDK update
This updates the SDK from internal repo commit segmentio/public-api@62c5da31.
1 parent 8c132fe commit 073fe07

File tree

9 files changed

+1579
-16
lines changed

9 files changed

+1579
-16
lines changed

docs/AudiencesApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class Example {
9393
9494
Get Audience
9595

96-
Returns the Audience by id and spaceId. • This endpoint is in **Alpha** testing. Please submit any feedback by sending an email to [email protected]. • In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information. The rate limit for this endpoint is 100 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See [Rate Limiting](/#tag/Rate-Limits) for more information.
96+
Returns the Audience by id and spaceId. • This endpoint is in **Beta** testing. Please submit any feedback by sending an email to [email protected]. • In order to successfully call this endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach out to your customer success manager for more information. The rate limit for this endpoint is 100 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See [Rate Limiting](/#tag/Rate-Limits) for more information.
9797

9898
### Example
9999

@@ -150,7 +150,7 @@ public class Example {
150150
### HTTP request headers
151151

152152
- **Content-Type**: Not defined
153-
- **Accept**: application/vnd.segment.v1alpha+json, application/json
153+
- **Accept**: application/vnd.segment.v1beta+json, application/vnd.segment.v1alpha+json, application/json
154154

155155

156156
### HTTP response details

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,16 @@ private static Class getClassByDiscriminator(
168168
.CustomTypeAdapterFactory());
169169
gsonBuilder.registerTypeAdapterFactory(
170170
new com.segment.publicapi.models.AudienceDefinition.CustomTypeAdapterFactory());
171+
gsonBuilder.registerTypeAdapterFactory(
172+
new com.segment.publicapi.models.AudienceDefinitionBeta.CustomTypeAdapterFactory());
171173
gsonBuilder.registerTypeAdapterFactory(
172174
new com.segment.publicapi.models.AudienceOptions.CustomTypeAdapterFactory());
175+
gsonBuilder.registerTypeAdapterFactory(
176+
new com.segment.publicapi.models.AudienceOptionsBeta.CustomTypeAdapterFactory());
173177
gsonBuilder.registerTypeAdapterFactory(
174178
new com.segment.publicapi.models.AudienceSummary.CustomTypeAdapterFactory());
179+
gsonBuilder.registerTypeAdapterFactory(
180+
new com.segment.publicapi.models.AudienceSummaryBeta.CustomTypeAdapterFactory());
175181
gsonBuilder.registerTypeAdapterFactory(
176182
new com.segment.publicapi.models.AuditEventV1.CustomTypeAdapterFactory());
177183
gsonBuilder.registerTypeAdapterFactory(
@@ -629,8 +635,13 @@ private static Class getClassByDiscriminator(
629635
.CustomTypeAdapterFactory());
630636
gsonBuilder.registerTypeAdapterFactory(
631637
new com.segment.publicapi.models.GetAudience200Response.CustomTypeAdapterFactory());
638+
gsonBuilder.registerTypeAdapterFactory(
639+
new com.segment.publicapi.models.GetAudience200Response1
640+
.CustomTypeAdapterFactory());
632641
gsonBuilder.registerTypeAdapterFactory(
633642
new com.segment.publicapi.models.GetAudienceAlphaOutput.CustomTypeAdapterFactory());
643+
gsonBuilder.registerTypeAdapterFactory(
644+
new com.segment.publicapi.models.GetAudienceBetaOutput.CustomTypeAdapterFactory());
634645
gsonBuilder.registerTypeAdapterFactory(
635646
new com.segment.publicapi.models.GetComputedTrait200Response
636647
.CustomTypeAdapterFactory());

src/main/java/com/segment/publicapi/api/AudiencesApi.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ public okhttp3.Call getAudienceCall(String spaceId, String id, final ApiCallback
327327
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
328328

329329
final String[] localVarAccepts = {
330-
"application/vnd.segment.v1alpha+json", "application/json"
330+
"application/vnd.segment.v1beta+json",
331+
"application/vnd.segment.v1alpha+json",
332+
"application/json"
331333
};
332334
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
333335
if (localVarAccept != null) {
@@ -375,7 +377,7 @@ private okhttp3.Call getAudienceValidateBeforeCall(
375377
}
376378

377379
/**
378-
* Get Audience Returns the Audience by id and spaceId. • This endpoint is in **Alpha** testing.
380+
* Get Audience Returns the Audience by id and spaceId. • This endpoint is in **Beta** testing.
379381
* Please submit any feedback by sending an email to [email protected]. • In order to
380382
* successfully call this endpoint, the specified Workspace needs to have the Audience feature
381383
* enabled. Please reach out to your customer success manager for more information. The rate
@@ -404,7 +406,7 @@ public GetAudience200Response getAudience(String spaceId, String id) throws ApiE
404406
}
405407

406408
/**
407-
* Get Audience Returns the Audience by id and spaceId. • This endpoint is in **Alpha** testing.
409+
* Get Audience Returns the Audience by id and spaceId. • This endpoint is in **Beta** testing.
408410
* Please submit any feedback by sending an email to [email protected]. • In order to
409411
* successfully call this endpoint, the specified Workspace needs to have the Audience feature
410412
* enabled. Please reach out to your customer success manager for more information. The rate
@@ -436,12 +438,12 @@ public ApiResponse<GetAudience200Response> getAudienceWithHttpInfo(String spaceI
436438

437439
/**
438440
* Get Audience (asynchronously) Returns the Audience by id and spaceId. • This endpoint is in
439-
* **Alpha** testing. Please submit any feedback by sending an email to [email protected]. •
440-
* In order to successfully call this endpoint, the specified Workspace needs to have the
441-
* Audience feature enabled. Please reach out to your customer success manager for more
442-
* information. The rate limit for this endpoint is 100 requests per minute, which is lower than
443-
* the default due to access pattern restrictions. Once reached, this endpoint will respond with
444-
* the 429 HTTP status code with headers indicating the limit parameters. See [Rate
441+
* **Beta** testing. Please submit any feedback by sending an email to [email protected]. • In
442+
* order to successfully call this endpoint, the specified Workspace needs to have the Audience
443+
* feature enabled. Please reach out to your customer success manager for more information. The
444+
* rate limit for this endpoint is 100 requests per minute, which is lower than the default due
445+
* to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP
446+
* status code with headers indicating the limit parameters. See [Rate
445447
* Limiting](/#tag/Rate-Limits) for more information.
446448
*
447449
* @param spaceId (required)
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
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.JsonAdapter;
20+
import com.google.gson.annotations.SerializedName;
21+
import com.google.gson.reflect.TypeToken;
22+
import com.google.gson.stream.JsonReader;
23+
import com.google.gson.stream.JsonWriter;
24+
import com.segment.publicapi.JSON;
25+
import java.io.IOException;
26+
import java.util.HashSet;
27+
import java.util.Map;
28+
import java.util.Objects;
29+
import java.util.Set;
30+
31+
/** Defines an audience definition. */
32+
public class AudienceDefinitionBeta {
33+
public static final String SERIALIZED_NAME_QUERY = "query";
34+
35+
@SerializedName(SERIALIZED_NAME_QUERY)
36+
private String query;
37+
38+
/**
39+
* The underlying data type being segmented for this audience. Possible values: users, accounts.
40+
*/
41+
@JsonAdapter(TypeEnum.Adapter.class)
42+
public enum TypeEnum {
43+
ACCOUNTS("ACCOUNTS"),
44+
45+
USERS("USERS");
46+
47+
private String value;
48+
49+
TypeEnum(String value) {
50+
this.value = value;
51+
}
52+
53+
public String getValue() {
54+
return value;
55+
}
56+
57+
@Override
58+
public String toString() {
59+
return String.valueOf(value);
60+
}
61+
62+
public static TypeEnum fromValue(String value) {
63+
for (TypeEnum b : TypeEnum.values()) {
64+
if (b.value.equals(value)) {
65+
return b;
66+
}
67+
}
68+
throw new IllegalArgumentException("Unexpected value '" + value + "'");
69+
}
70+
71+
public static class Adapter extends TypeAdapter<TypeEnum> {
72+
@Override
73+
public void write(final JsonWriter jsonWriter, final TypeEnum enumeration)
74+
throws IOException {
75+
jsonWriter.value(enumeration.getValue());
76+
}
77+
78+
@Override
79+
public TypeEnum read(final JsonReader jsonReader) throws IOException {
80+
String value = jsonReader.nextString();
81+
return TypeEnum.fromValue(value);
82+
}
83+
}
84+
}
85+
86+
public static final String SERIALIZED_NAME_TYPE = "type";
87+
88+
@SerializedName(SERIALIZED_NAME_TYPE)
89+
private TypeEnum type;
90+
91+
public AudienceDefinitionBeta() {}
92+
93+
public AudienceDefinitionBeta query(String query) {
94+
95+
this.query = query;
96+
return this;
97+
}
98+
99+
/**
100+
* The query language string defining the audience segmentation criteria.
101+
*
102+
* @return query
103+
*/
104+
@javax.annotation.Nonnull
105+
public String getQuery() {
106+
return query;
107+
}
108+
109+
public void setQuery(String query) {
110+
this.query = query;
111+
}
112+
113+
public AudienceDefinitionBeta type(TypeEnum type) {
114+
115+
this.type = type;
116+
return this;
117+
}
118+
119+
/**
120+
* The underlying data type being segmented for this audience. Possible values: users, accounts.
121+
*
122+
* @return type
123+
*/
124+
@javax.annotation.Nonnull
125+
public TypeEnum getType() {
126+
return type;
127+
}
128+
129+
public void setType(TypeEnum type) {
130+
this.type = type;
131+
}
132+
133+
@Override
134+
public boolean equals(Object o) {
135+
if (this == o) {
136+
return true;
137+
}
138+
if (o == null || getClass() != o.getClass()) {
139+
return false;
140+
}
141+
AudienceDefinitionBeta audienceDefinitionBeta = (AudienceDefinitionBeta) o;
142+
return Objects.equals(this.query, audienceDefinitionBeta.query)
143+
&& Objects.equals(this.type, audienceDefinitionBeta.type);
144+
}
145+
146+
@Override
147+
public int hashCode() {
148+
return Objects.hash(query, type);
149+
}
150+
151+
@Override
152+
public String toString() {
153+
StringBuilder sb = new StringBuilder();
154+
sb.append("class AudienceDefinitionBeta {\n");
155+
sb.append(" query: ").append(toIndentedString(query)).append("\n");
156+
sb.append(" type: ").append(toIndentedString(type)).append("\n");
157+
sb.append("}");
158+
return sb.toString();
159+
}
160+
161+
/**
162+
* Convert the given object to string with each line indented by 4 spaces (except the first
163+
* line).
164+
*/
165+
private String toIndentedString(Object o) {
166+
if (o == null) {
167+
return "null";
168+
}
169+
return o.toString().replace("\n", "\n ");
170+
}
171+
172+
public static HashSet<String> openapiFields;
173+
public static HashSet<String> openapiRequiredFields;
174+
175+
static {
176+
// a set of all properties/fields (JSON key names)
177+
openapiFields = new HashSet<String>();
178+
openapiFields.add("query");
179+
openapiFields.add("type");
180+
181+
// a set of required properties/fields (JSON key names)
182+
openapiRequiredFields = new HashSet<String>();
183+
openapiRequiredFields.add("query");
184+
openapiRequiredFields.add("type");
185+
}
186+
187+
/**
188+
* Validates the JSON Element and throws an exception if issues found
189+
*
190+
* @param jsonElement JSON Element
191+
* @throws IOException if the JSON Element is invalid with respect to AudienceDefinitionBeta
192+
*/
193+
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
194+
if (jsonElement == null) {
195+
if (!AudienceDefinitionBeta.openapiRequiredFields
196+
.isEmpty()) { // has required fields but JSON element is null
197+
throw new IllegalArgumentException(
198+
String.format(
199+
"The required field(s) %s in AudienceDefinitionBeta is not found in"
200+
+ " the empty JSON string",
201+
AudienceDefinitionBeta.openapiRequiredFields.toString()));
202+
}
203+
}
204+
205+
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
206+
// check to see if the JSON string contains additional fields
207+
for (Map.Entry<String, JsonElement> entry : entries) {
208+
if (!AudienceDefinitionBeta.openapiFields.contains(entry.getKey())) {
209+
throw new IllegalArgumentException(
210+
String.format(
211+
"The field `%s` in the JSON string is not defined in the"
212+
+ " `AudienceDefinitionBeta` properties. JSON: %s",
213+
entry.getKey(), jsonElement.toString()));
214+
}
215+
}
216+
217+
// check to make sure all required properties/fields are present in the JSON string
218+
for (String requiredField : AudienceDefinitionBeta.openapiRequiredFields) {
219+
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
220+
throw new IllegalArgumentException(
221+
String.format(
222+
"The required field `%s` is not found in the JSON string: %s",
223+
requiredField, jsonElement.toString()));
224+
}
225+
}
226+
JsonObject jsonObj = jsonElement.getAsJsonObject();
227+
if (!jsonObj.get("query").isJsonPrimitive()) {
228+
throw new IllegalArgumentException(
229+
String.format(
230+
"Expected the field `query` to be a primitive type in the JSON string"
231+
+ " but got `%s`",
232+
jsonObj.get("query").toString()));
233+
}
234+
if (!jsonObj.get("type").isJsonPrimitive()) {
235+
throw new IllegalArgumentException(
236+
String.format(
237+
"Expected the field `type` to be a primitive type in the JSON string"
238+
+ " but got `%s`",
239+
jsonObj.get("type").toString()));
240+
}
241+
}
242+
243+
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
244+
@SuppressWarnings("unchecked")
245+
@Override
246+
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
247+
if (!AudienceDefinitionBeta.class.isAssignableFrom(type.getRawType())) {
248+
return null; // this class only serializes 'AudienceDefinitionBeta' and its subtypes
249+
}
250+
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
251+
final TypeAdapter<AudienceDefinitionBeta> thisAdapter =
252+
gson.getDelegateAdapter(this, TypeToken.get(AudienceDefinitionBeta.class));
253+
254+
return (TypeAdapter<T>)
255+
new TypeAdapter<AudienceDefinitionBeta>() {
256+
@Override
257+
public void write(JsonWriter out, AudienceDefinitionBeta value)
258+
throws IOException {
259+
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
260+
elementAdapter.write(out, obj);
261+
}
262+
263+
@Override
264+
public AudienceDefinitionBeta read(JsonReader in) throws IOException {
265+
JsonElement jsonElement = elementAdapter.read(in);
266+
validateJsonElement(jsonElement);
267+
return thisAdapter.fromJsonTree(jsonElement);
268+
}
269+
}.nullSafe();
270+
}
271+
}
272+
273+
/**
274+
* Create an instance of AudienceDefinitionBeta given an JSON string
275+
*
276+
* @param jsonString JSON string
277+
* @return An instance of AudienceDefinitionBeta
278+
* @throws IOException if the JSON string is invalid with respect to AudienceDefinitionBeta
279+
*/
280+
public static AudienceDefinitionBeta fromJson(String jsonString) throws IOException {
281+
return JSON.getGson().fromJson(jsonString, AudienceDefinitionBeta.class);
282+
}
283+
284+
/**
285+
* Convert an instance of AudienceDefinitionBeta to an JSON string
286+
*
287+
* @return JSON string
288+
*/
289+
public String toJson() {
290+
return JSON.getGson().toJson(this);
291+
}
292+
}

0 commit comments

Comments
 (0)