Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 23e9680

Browse files
author
APIs and Common Services team
committedApr 10, 2025·
Automated SDK update
This updates the SDK from internal repo commit segmentio/public-api@457f3203.
1 parent b935785 commit 23e9680

File tree

9 files changed

+815
-7
lines changed

9 files changed

+815
-7
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.0.1
13+
Latest API and SDK version: 58.1.1
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.0.1</version>
31+
<version>58.1.1</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.0.1"
47+
implementation "com.segment.publicapi:segment-publicapi:58.1.1"
4848
}
4949
```
5050

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

5959
Then manually install the following JARs:
6060

61-
* `target/segment-publicapi-58.0.1.jar`
61+
* `target/segment-publicapi-58.1.1.jar`
6262
* `target/lib/*.jar`
6363

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

‎docs/AudiencesApi.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All URIs are relative to *https://api.segmentapis.com*
66
|------------- | ------------- | -------------|
77
| [**createAudience**](AudiencesApi.md#createAudience) | **POST** /spaces/{spaceId}/audiences | Create Audience |
88
| [**getAudience**](AudiencesApi.md#getAudience) | **GET** /spaces/{spaceId}/audiences/{id} | Get Audience |
9+
| [**listAudienceConsumersFromSpaceAndAudience**](AudiencesApi.md#listAudienceConsumersFromSpaceAndAudience) | **GET** /spaces/{spaceId}/audiences/{id}/audience-references | List Audience Consumers from Space And Audience |
910
| [**listAudiences**](AudiencesApi.md#listAudiences) | **GET** /spaces/{spaceId}/audiences | List Audiences |
1011
| [**removeAudienceFromSpace**](AudiencesApi.md#removeAudienceFromSpace) | **DELETE** /spaces/{spaceId}/audiences/{id} | Remove Audience from Space |
1112
| [**updateAudienceForSpace**](AudiencesApi.md#updateAudienceForSpace) | **PATCH** /spaces/{spaceId}/audiences/{id} | Update Audience for Space |
@@ -162,6 +163,83 @@ public class Example {
162163
| **429** | Too many requests | - |
163164

164165

166+
## Operation: listAudienceConsumersFromSpaceAndAudience
167+
168+
> ListAudienceConsumersFromSpaceAndAudience200Response listAudienceConsumersFromSpaceAndAudience(spaceId, id, pagination)
169+
170+
List Audience Consumers from Space And Audience
171+
172+
Returns the list of consumers for the given audience. • This endpoint is in **Alpha** testing. Please submit any feedback by sending an email to friends@segment.com. • 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 25 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.
173+
174+
### Example
175+
176+
```java
177+
// Import classes:
178+
import com.segment.publicapi.ApiClient;
179+
import com.segment.publicapi.ApiException;
180+
import com.segment.publicapi.Configuration;
181+
import com.segment.publicapi.auth.*;
182+
import com.segment.publicapi.models.*;
183+
import com.segment.publicapi.api.AudiencesApi;
184+
185+
public class Example {
186+
public static void main(String[] args) {
187+
ApiClient defaultClient = Configuration.getDefaultApiClient();
188+
189+
// Configure HTTP bearer authorization: token
190+
HttpBearerAuth token = (HttpBearerAuth) defaultClient.getAuthentication("token");
191+
token.setBearerToken("BEARER TOKEN");
192+
193+
AudiencesApi apiInstance = new AudiencesApi(defaultClient);
194+
String spaceId = "spaceId"; // String |
195+
String id = "ReferencedAudienceId"; // String |
196+
PaginationInput pagination = new PaginationInput(); // PaginationInput | Information about the pagination of this response. [See pagination](https://docs.segmentapis.com/tag/Pagination/#section/Pagination-parameters) for more info. This parameter exists in alpha.
197+
try {
198+
ListAudienceConsumersFromSpaceAndAudience200Response result = apiInstance.listAudienceConsumersFromSpaceAndAudience(spaceId, id, pagination);
199+
System.out.println(result);
200+
} catch (ApiException e) {
201+
System.err.println("Exception when calling AudiencesApi#listAudienceConsumersFromSpaceAndAudience");
202+
System.err.println("Status code: " + e.getCode());
203+
System.err.println("Reason: " + e.getResponseBody());
204+
System.err.println("Response headers: " + e.getResponseHeaders());
205+
e.printStackTrace();
206+
}
207+
}
208+
}
209+
```
210+
211+
### Parameters
212+
213+
214+
| Name | Type | Description | Notes |
215+
|------------- | ------------- | ------------- | -------------|
216+
| **spaceId** | **String**| | |
217+
| **id** | **String**| | |
218+
| **pagination** | [**PaginationInput**](.md)| Information about the pagination of this response. [See pagination](https://docs.segmentapis.com/tag/Pagination/#section/Pagination-parameters) for more info. This parameter exists in alpha. | [optional] |
219+
220+
### Return type
221+
222+
[**ListAudienceConsumersFromSpaceAndAudience200Response**](ListAudienceConsumersFromSpaceAndAudience200Response.md)
223+
224+
### Authorization
225+
226+
[token](../README.md#token)
227+
228+
### HTTP request headers
229+
230+
- **Content-Type**: Not defined
231+
- **Accept**: application/vnd.segment.v1alpha+json, application/json
232+
233+
234+
### HTTP response details
235+
| Status code | Description | Response headers |
236+
|-------------|-------------|------------------|
237+
| **200** | OK | - |
238+
| **404** | Resource not found | - |
239+
| **422** | Validation failure | - |
240+
| **429** | Too many requests | - |
241+
242+
165243
## Operation: listAudiences
166244

167245
> ListAudiences200Response listAudiences(spaceId, pagination)

‎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.0.1</version>
8+
<version>58.1.1</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.0.1 (Java)");
126+
setUserAgent("Public API SDK 58.1.1 (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.0.1";
15+
public static final String VERSION = "58.1.1";
1616

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

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,13 @@ private static Class getClassByDiscriminator(
879879
new com.segment.publicapi.models.LabelAlpha.CustomTypeAdapterFactory());
880880
gsonBuilder.registerTypeAdapterFactory(
881881
new com.segment.publicapi.models.LabelV1.CustomTypeAdapterFactory());
882+
gsonBuilder.registerTypeAdapterFactory(
883+
new com.segment.publicapi.models
884+
.ListAudienceConsumersFromSpaceAndAudience200Response
885+
.CustomTypeAdapterFactory());
886+
gsonBuilder.registerTypeAdapterFactory(
887+
new com.segment.publicapi.models.ListAudienceConsumersFromSpaceAndAudienceOutput
888+
.CustomTypeAdapterFactory());
882889
gsonBuilder.registerTypeAdapterFactory(
883890
new com.segment.publicapi.models.ListAudiences200Response
884891
.CustomTypeAdapterFactory());

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

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.segment.publicapi.models.CreateAudience200Response;
2222
import com.segment.publicapi.models.CreateAudienceAlphaInput;
2323
import com.segment.publicapi.models.GetAudience200Response;
24+
import com.segment.publicapi.models.ListAudienceConsumersFromSpaceAndAudience200Response;
2425
import com.segment.publicapi.models.ListAudiences200Response;
2526
import com.segment.publicapi.models.PaginationInput;
2627
import com.segment.publicapi.models.RemoveAudienceFromSpace200Response;
@@ -471,6 +472,231 @@ public okhttp3.Call getAudienceAsync(
471472
return localVarCall;
472473
}
473474

475+
/**
476+
* Build call for listAudienceConsumersFromSpaceAndAudience
477+
*
478+
* @param spaceId (required)
479+
* @param id (required)
480+
* @param pagination Information about the pagination of this response. [See
481+
* pagination](https://docs.segmentapis.com/tag/Pagination/#section/Pagination-parameters)
482+
* for more info. This parameter exists in alpha. (optional)
483+
* @param _callback Callback for upload/download progress
484+
* @return Call to execute
485+
* @throws ApiException If fail to serialize the request body object
486+
* @http.response.details
487+
* <table summary="Response Details" border="1">
488+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
489+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
490+
* <tr><td> 404 </td><td> Resource not found </td><td> - </td></tr>
491+
* <tr><td> 422 </td><td> Validation failure </td><td> - </td></tr>
492+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
493+
* </table>
494+
*/
495+
public okhttp3.Call listAudienceConsumersFromSpaceAndAudienceCall(
496+
String spaceId, String id, PaginationInput pagination, final ApiCallback _callback)
497+
throws ApiException {
498+
String basePath = null;
499+
// Operation Servers
500+
String[] localBasePaths = new String[] {};
501+
502+
// Determine Base Path to Use
503+
if (localCustomBaseUrl != null) {
504+
basePath = localCustomBaseUrl;
505+
} else if (localBasePaths.length > 0) {
506+
basePath = localBasePaths[localHostIndex];
507+
} else {
508+
basePath = null;
509+
}
510+
511+
Object localVarPostBody = null;
512+
513+
// create path and map variables
514+
String localVarPath =
515+
"/spaces/{spaceId}/audiences/{id}/audience-references"
516+
.replace(
517+
"{" + "spaceId" + "}",
518+
localVarApiClient.escapeString(spaceId.toString()))
519+
.replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString()));
520+
521+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
522+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
523+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
524+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
525+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
526+
527+
if (pagination != null) {
528+
localVarQueryParams.addAll(localVarApiClient.parameterToPair("pagination", pagination));
529+
}
530+
531+
final String[] localVarAccepts = {
532+
"application/vnd.segment.v1alpha+json", "application/json"
533+
};
534+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
535+
if (localVarAccept != null) {
536+
localVarHeaderParams.put("Accept", localVarAccept);
537+
}
538+
539+
final String[] localVarContentTypes = {};
540+
final String localVarContentType =
541+
localVarApiClient.selectHeaderContentType(localVarContentTypes);
542+
if (localVarContentType != null) {
543+
localVarHeaderParams.put("Content-Type", localVarContentType);
544+
}
545+
546+
String[] localVarAuthNames = new String[] {"token"};
547+
return localVarApiClient.buildCall(
548+
basePath,
549+
localVarPath,
550+
"GET",
551+
localVarQueryParams,
552+
localVarCollectionQueryParams,
553+
localVarPostBody,
554+
localVarHeaderParams,
555+
localVarCookieParams,
556+
localVarFormParams,
557+
localVarAuthNames,
558+
_callback);
559+
}
560+
561+
@SuppressWarnings("rawtypes")
562+
private okhttp3.Call listAudienceConsumersFromSpaceAndAudienceValidateBeforeCall(
563+
String spaceId, String id, PaginationInput pagination, final ApiCallback _callback)
564+
throws ApiException {
565+
// verify the required parameter 'spaceId' is set
566+
if (spaceId == null) {
567+
throw new ApiException(
568+
"Missing the required parameter 'spaceId' when calling"
569+
+ " listAudienceConsumersFromSpaceAndAudience(Async)");
570+
}
571+
572+
// verify the required parameter 'id' is set
573+
if (id == null) {
574+
throw new ApiException(
575+
"Missing the required parameter 'id' when calling"
576+
+ " listAudienceConsumersFromSpaceAndAudience(Async)");
577+
}
578+
579+
return listAudienceConsumersFromSpaceAndAudienceCall(spaceId, id, pagination, _callback);
580+
}
581+
582+
/**
583+
* List Audience Consumers from Space And Audience Returns the list of consumers for the given
584+
* audience. • This endpoint is in **Alpha** testing. Please submit any feedback by sending an
585+
* email to friends@segment.com. • In order to successfully call this endpoint, the specified
586+
* Workspace needs to have the Audience feature enabled. Please reach out to your customer
587+
* success manager for more information. The rate limit for this endpoint is 25 requests per
588+
* minute, which is lower than the default due to access pattern restrictions. Once reached,
589+
* this endpoint will respond with the 429 HTTP status code with headers indicating the limit
590+
* parameters. See [Rate Limiting](/#tag/Rate-Limits) for more information.
591+
*
592+
* @param spaceId (required)
593+
* @param id (required)
594+
* @param pagination Information about the pagination of this response. [See
595+
* pagination](https://docs.segmentapis.com/tag/Pagination/#section/Pagination-parameters)
596+
* for more info. This parameter exists in alpha. (optional)
597+
* @return ListAudienceConsumersFromSpaceAndAudience200Response
598+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
599+
* response body
600+
* @http.response.details
601+
* <table summary="Response Details" border="1">
602+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
603+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
604+
* <tr><td> 404 </td><td> Resource not found </td><td> - </td></tr>
605+
* <tr><td> 422 </td><td> Validation failure </td><td> - </td></tr>
606+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
607+
* </table>
608+
*/
609+
public ListAudienceConsumersFromSpaceAndAudience200Response
610+
listAudienceConsumersFromSpaceAndAudience(
611+
String spaceId, String id, PaginationInput pagination) throws ApiException {
612+
ApiResponse<ListAudienceConsumersFromSpaceAndAudience200Response> localVarResp =
613+
listAudienceConsumersFromSpaceAndAudienceWithHttpInfo(spaceId, id, pagination);
614+
return localVarResp.getData();
615+
}
616+
617+
/**
618+
* List Audience Consumers from Space And Audience Returns the list of consumers for the given
619+
* audience. • This endpoint is in **Alpha** testing. Please submit any feedback by sending an
620+
* email to friends@segment.com. • In order to successfully call this endpoint, the specified
621+
* Workspace needs to have the Audience feature enabled. Please reach out to your customer
622+
* success manager for more information. The rate limit for this endpoint is 25 requests per
623+
* minute, which is lower than the default due to access pattern restrictions. Once reached,
624+
* this endpoint will respond with the 429 HTTP status code with headers indicating the limit
625+
* parameters. See [Rate Limiting](/#tag/Rate-Limits) for more information.
626+
*
627+
* @param spaceId (required)
628+
* @param id (required)
629+
* @param pagination Information about the pagination of this response. [See
630+
* pagination](https://docs.segmentapis.com/tag/Pagination/#section/Pagination-parameters)
631+
* for more info. This parameter exists in alpha. (optional)
632+
* @return ApiResponse&lt;ListAudienceConsumersFromSpaceAndAudience200Response&gt;
633+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
634+
* response body
635+
* @http.response.details
636+
* <table summary="Response Details" border="1">
637+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
638+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
639+
* <tr><td> 404 </td><td> Resource not found </td><td> - </td></tr>
640+
* <tr><td> 422 </td><td> Validation failure </td><td> - </td></tr>
641+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
642+
* </table>
643+
*/
644+
public ApiResponse<ListAudienceConsumersFromSpaceAndAudience200Response>
645+
listAudienceConsumersFromSpaceAndAudienceWithHttpInfo(
646+
String spaceId, String id, PaginationInput pagination) throws ApiException {
647+
okhttp3.Call localVarCall =
648+
listAudienceConsumersFromSpaceAndAudienceValidateBeforeCall(
649+
spaceId, id, pagination, null);
650+
Type localVarReturnType =
651+
new TypeToken<ListAudienceConsumersFromSpaceAndAudience200Response>() {}.getType();
652+
return localVarApiClient.execute(localVarCall, localVarReturnType);
653+
}
654+
655+
/**
656+
* List Audience Consumers from Space And Audience (asynchronously) Returns the list of
657+
* consumers for the given audience. • This endpoint is in **Alpha** testing. Please submit any
658+
* feedback by sending an email to friends@segment.com. • In order to successfully call this
659+
* endpoint, the specified Workspace needs to have the Audience feature enabled. Please reach
660+
* out to your customer success manager for more information. The rate limit for this endpoint
661+
* is 25 requests per minute, which is lower than the default due to access pattern
662+
* restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with
663+
* headers indicating the limit parameters. See [Rate Limiting](/#tag/Rate-Limits) for more
664+
* information.
665+
*
666+
* @param spaceId (required)
667+
* @param id (required)
668+
* @param pagination Information about the pagination of this response. [See
669+
* pagination](https://docs.segmentapis.com/tag/Pagination/#section/Pagination-parameters)
670+
* for more info. This parameter exists in alpha. (optional)
671+
* @param _callback The callback to be executed when the API call finishes
672+
* @return The request call
673+
* @throws ApiException If fail to process the API call, e.g. serializing the request body
674+
* object
675+
* @http.response.details
676+
* <table summary="Response Details" border="1">
677+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
678+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
679+
* <tr><td> 404 </td><td> Resource not found </td><td> - </td></tr>
680+
* <tr><td> 422 </td><td> Validation failure </td><td> - </td></tr>
681+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
682+
* </table>
683+
*/
684+
public okhttp3.Call listAudienceConsumersFromSpaceAndAudienceAsync(
685+
String spaceId,
686+
String id,
687+
PaginationInput pagination,
688+
final ApiCallback<ListAudienceConsumersFromSpaceAndAudience200Response> _callback)
689+
throws ApiException {
690+
691+
okhttp3.Call localVarCall =
692+
listAudienceConsumersFromSpaceAndAudienceValidateBeforeCall(
693+
spaceId, id, pagination, _callback);
694+
Type localVarReturnType =
695+
new TypeToken<ListAudienceConsumersFromSpaceAndAudience200Response>() {}.getType();
696+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
697+
return localVarCall;
698+
}
699+
474700
/**
475701
* Build call for listAudiences
476702
*
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
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: friends@segment.com
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+
/** ListAudienceConsumersFromSpaceAndAudience200Response */
31+
public class ListAudienceConsumersFromSpaceAndAudience200Response {
32+
public static final String SERIALIZED_NAME_DATA = "data";
33+
34+
@SerializedName(SERIALIZED_NAME_DATA)
35+
private ListAudienceConsumersFromSpaceAndAudienceOutput data;
36+
37+
public ListAudienceConsumersFromSpaceAndAudience200Response() {}
38+
39+
public ListAudienceConsumersFromSpaceAndAudience200Response data(
40+
ListAudienceConsumersFromSpaceAndAudienceOutput data) {
41+
42+
this.data = data;
43+
return this;
44+
}
45+
46+
/**
47+
* Get data
48+
*
49+
* @return data
50+
*/
51+
@javax.annotation.Nullable
52+
public ListAudienceConsumersFromSpaceAndAudienceOutput getData() {
53+
return data;
54+
}
55+
56+
public void setData(ListAudienceConsumersFromSpaceAndAudienceOutput data) {
57+
this.data = data;
58+
}
59+
60+
@Override
61+
public boolean equals(Object o) {
62+
if (this == o) {
63+
return true;
64+
}
65+
if (o == null || getClass() != o.getClass()) {
66+
return false;
67+
}
68+
ListAudienceConsumersFromSpaceAndAudience200Response
69+
listAudienceConsumersFromSpaceAndAudience200Response =
70+
(ListAudienceConsumersFromSpaceAndAudience200Response) o;
71+
return Objects.equals(this.data, listAudienceConsumersFromSpaceAndAudience200Response.data);
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
return Objects.hash(data);
77+
}
78+
79+
@Override
80+
public String toString() {
81+
StringBuilder sb = new StringBuilder();
82+
sb.append("class ListAudienceConsumersFromSpaceAndAudience200Response {\n");
83+
sb.append(" data: ").append(toIndentedString(data)).append("\n");
84+
sb.append("}");
85+
return sb.toString();
86+
}
87+
88+
/**
89+
* Convert the given object to string with each line indented by 4 spaces (except the first
90+
* line).
91+
*/
92+
private String toIndentedString(Object o) {
93+
if (o == null) {
94+
return "null";
95+
}
96+
return o.toString().replace("\n", "\n ");
97+
}
98+
99+
public static HashSet<String> openapiFields;
100+
public static HashSet<String> openapiRequiredFields;
101+
102+
static {
103+
// a set of all properties/fields (JSON key names)
104+
openapiFields = new HashSet<String>();
105+
openapiFields.add("data");
106+
107+
// a set of required properties/fields (JSON key names)
108+
openapiRequiredFields = new HashSet<String>();
109+
}
110+
111+
/**
112+
* Validates the JSON Element and throws an exception if issues found
113+
*
114+
* @param jsonElement JSON Element
115+
* @throws IOException if the JSON Element is invalid with respect to
116+
* ListAudienceConsumersFromSpaceAndAudience200Response
117+
*/
118+
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
119+
if (jsonElement == null) {
120+
if (!ListAudienceConsumersFromSpaceAndAudience200Response.openapiRequiredFields
121+
.isEmpty()) { // has required fields but JSON element is null
122+
throw new IllegalArgumentException(
123+
String.format(
124+
"The required field(s) %s in"
125+
+ " ListAudienceConsumersFromSpaceAndAudience200Response is not"
126+
+ " found in the empty JSON string",
127+
ListAudienceConsumersFromSpaceAndAudience200Response
128+
.openapiRequiredFields
129+
.toString()));
130+
}
131+
}
132+
133+
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
134+
// check to see if the JSON string contains additional fields
135+
for (Map.Entry<String, JsonElement> entry : entries) {
136+
if (!ListAudienceConsumersFromSpaceAndAudience200Response.openapiFields.contains(
137+
entry.getKey())) {
138+
throw new IllegalArgumentException(
139+
String.format(
140+
"The field `%s` in the JSON string is not defined in the"
141+
+ " `ListAudienceConsumersFromSpaceAndAudience200Response`"
142+
+ " properties. JSON: %s",
143+
entry.getKey(), jsonElement.toString()));
144+
}
145+
}
146+
JsonObject jsonObj = jsonElement.getAsJsonObject();
147+
// validate the optional field `data`
148+
if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) {
149+
ListAudienceConsumersFromSpaceAndAudienceOutput.validateJsonElement(
150+
jsonObj.get("data"));
151+
}
152+
}
153+
154+
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
155+
@SuppressWarnings("unchecked")
156+
@Override
157+
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
158+
if (!ListAudienceConsumersFromSpaceAndAudience200Response.class.isAssignableFrom(
159+
type.getRawType())) {
160+
return null; // this class only serializes
161+
// 'ListAudienceConsumersFromSpaceAndAudience200Response' and its
162+
// subtypes
163+
}
164+
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
165+
final TypeAdapter<ListAudienceConsumersFromSpaceAndAudience200Response> thisAdapter =
166+
gson.getDelegateAdapter(
167+
this,
168+
TypeToken.get(
169+
ListAudienceConsumersFromSpaceAndAudience200Response.class));
170+
171+
return (TypeAdapter<T>)
172+
new TypeAdapter<ListAudienceConsumersFromSpaceAndAudience200Response>() {
173+
@Override
174+
public void write(
175+
JsonWriter out,
176+
ListAudienceConsumersFromSpaceAndAudience200Response value)
177+
throws IOException {
178+
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
179+
elementAdapter.write(out, obj);
180+
}
181+
182+
@Override
183+
public ListAudienceConsumersFromSpaceAndAudience200Response read(
184+
JsonReader in) throws IOException {
185+
JsonElement jsonElement = elementAdapter.read(in);
186+
validateJsonElement(jsonElement);
187+
return thisAdapter.fromJsonTree(jsonElement);
188+
}
189+
}.nullSafe();
190+
}
191+
}
192+
193+
/**
194+
* Create an instance of ListAudienceConsumersFromSpaceAndAudience200Response given an JSON
195+
* string
196+
*
197+
* @param jsonString JSON string
198+
* @return An instance of ListAudienceConsumersFromSpaceAndAudience200Response
199+
* @throws IOException if the JSON string is invalid with respect to
200+
* ListAudienceConsumersFromSpaceAndAudience200Response
201+
*/
202+
public static ListAudienceConsumersFromSpaceAndAudience200Response fromJson(String jsonString)
203+
throws IOException {
204+
return JSON.getGson()
205+
.fromJson(jsonString, ListAudienceConsumersFromSpaceAndAudience200Response.class);
206+
}
207+
208+
/**
209+
* Convert an instance of ListAudienceConsumersFromSpaceAndAudience200Response to an JSON string
210+
*
211+
* @return JSON string
212+
*/
213+
public String toJson() {
214+
return JSON.getGson().toJson(this);
215+
}
216+
}
Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
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: friends@segment.com
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.JsonArray;
16+
import com.google.gson.JsonElement;
17+
import com.google.gson.JsonObject;
18+
import com.google.gson.TypeAdapter;
19+
import com.google.gson.TypeAdapterFactory;
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.ArrayList;
27+
import java.util.HashSet;
28+
import java.util.List;
29+
import java.util.Map;
30+
import java.util.Objects;
31+
import java.util.Set;
32+
33+
/** List Audience consumers output. */
34+
public class ListAudienceConsumersFromSpaceAndAudienceOutput {
35+
public static final String SERIALIZED_NAME_AUDIENCES = "audiences";
36+
37+
@SerializedName(SERIALIZED_NAME_AUDIENCES)
38+
private List<AudienceSummary> audiences = new ArrayList<>();
39+
40+
public static final String SERIALIZED_NAME_PAGINATION = "pagination";
41+
42+
@SerializedName(SERIALIZED_NAME_PAGINATION)
43+
private PaginationOutput pagination;
44+
45+
public ListAudienceConsumersFromSpaceAndAudienceOutput() {}
46+
47+
public ListAudienceConsumersFromSpaceAndAudienceOutput audiences(
48+
List<AudienceSummary> audiences) {
49+
50+
this.audiences = audiences;
51+
return this;
52+
}
53+
54+
public ListAudienceConsumersFromSpaceAndAudienceOutput addAudiencesItem(
55+
AudienceSummary audiencesItem) {
56+
if (this.audiences == null) {
57+
this.audiences = new ArrayList<>();
58+
}
59+
this.audiences.add(audiencesItem);
60+
return this;
61+
}
62+
63+
/**
64+
* The list of audience consumers.
65+
*
66+
* @return audiences
67+
*/
68+
@javax.annotation.Nonnull
69+
public List<AudienceSummary> getAudiences() {
70+
return audiences;
71+
}
72+
73+
public void setAudiences(List<AudienceSummary> audiences) {
74+
this.audiences = audiences;
75+
}
76+
77+
public ListAudienceConsumersFromSpaceAndAudienceOutput pagination(PaginationOutput pagination) {
78+
79+
this.pagination = pagination;
80+
return this;
81+
}
82+
83+
/**
84+
* Get pagination
85+
*
86+
* @return pagination
87+
*/
88+
@javax.annotation.Nonnull
89+
public PaginationOutput getPagination() {
90+
return pagination;
91+
}
92+
93+
public void setPagination(PaginationOutput pagination) {
94+
this.pagination = pagination;
95+
}
96+
97+
@Override
98+
public boolean equals(Object o) {
99+
if (this == o) {
100+
return true;
101+
}
102+
if (o == null || getClass() != o.getClass()) {
103+
return false;
104+
}
105+
ListAudienceConsumersFromSpaceAndAudienceOutput
106+
listAudienceConsumersFromSpaceAndAudienceOutput =
107+
(ListAudienceConsumersFromSpaceAndAudienceOutput) o;
108+
return Objects.equals(
109+
this.audiences, listAudienceConsumersFromSpaceAndAudienceOutput.audiences)
110+
&& Objects.equals(
111+
this.pagination,
112+
listAudienceConsumersFromSpaceAndAudienceOutput.pagination);
113+
}
114+
115+
@Override
116+
public int hashCode() {
117+
return Objects.hash(audiences, pagination);
118+
}
119+
120+
@Override
121+
public String toString() {
122+
StringBuilder sb = new StringBuilder();
123+
sb.append("class ListAudienceConsumersFromSpaceAndAudienceOutput {\n");
124+
sb.append(" audiences: ").append(toIndentedString(audiences)).append("\n");
125+
sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n");
126+
sb.append("}");
127+
return sb.toString();
128+
}
129+
130+
/**
131+
* Convert the given object to string with each line indented by 4 spaces (except the first
132+
* line).
133+
*/
134+
private String toIndentedString(Object o) {
135+
if (o == null) {
136+
return "null";
137+
}
138+
return o.toString().replace("\n", "\n ");
139+
}
140+
141+
public static HashSet<String> openapiFields;
142+
public static HashSet<String> openapiRequiredFields;
143+
144+
static {
145+
// a set of all properties/fields (JSON key names)
146+
openapiFields = new HashSet<String>();
147+
openapiFields.add("audiences");
148+
openapiFields.add("pagination");
149+
150+
// a set of required properties/fields (JSON key names)
151+
openapiRequiredFields = new HashSet<String>();
152+
openapiRequiredFields.add("audiences");
153+
openapiRequiredFields.add("pagination");
154+
}
155+
156+
/**
157+
* Validates the JSON Element and throws an exception if issues found
158+
*
159+
* @param jsonElement JSON Element
160+
* @throws IOException if the JSON Element is invalid with respect to
161+
* ListAudienceConsumersFromSpaceAndAudienceOutput
162+
*/
163+
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
164+
if (jsonElement == null) {
165+
if (!ListAudienceConsumersFromSpaceAndAudienceOutput.openapiRequiredFields
166+
.isEmpty()) { // has required fields but JSON element is null
167+
throw new IllegalArgumentException(
168+
String.format(
169+
"The required field(s) %s in"
170+
+ " ListAudienceConsumersFromSpaceAndAudienceOutput is not"
171+
+ " found in the empty JSON string",
172+
ListAudienceConsumersFromSpaceAndAudienceOutput
173+
.openapiRequiredFields
174+
.toString()));
175+
}
176+
}
177+
178+
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
179+
// check to see if the JSON string contains additional fields
180+
for (Map.Entry<String, JsonElement> entry : entries) {
181+
if (!ListAudienceConsumersFromSpaceAndAudienceOutput.openapiFields.contains(
182+
entry.getKey())) {
183+
throw new IllegalArgumentException(
184+
String.format(
185+
"The field `%s` in the JSON string is not defined in the"
186+
+ " `ListAudienceConsumersFromSpaceAndAudienceOutput`"
187+
+ " properties. JSON: %s",
188+
entry.getKey(), jsonElement.toString()));
189+
}
190+
}
191+
192+
// check to make sure all required properties/fields are present in the JSON string
193+
for (String requiredField :
194+
ListAudienceConsumersFromSpaceAndAudienceOutput.openapiRequiredFields) {
195+
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
196+
throw new IllegalArgumentException(
197+
String.format(
198+
"The required field `%s` is not found in the JSON string: %s",
199+
requiredField, jsonElement.toString()));
200+
}
201+
}
202+
JsonObject jsonObj = jsonElement.getAsJsonObject();
203+
// ensure the json data is an array
204+
if (!jsonObj.get("audiences").isJsonArray()) {
205+
throw new IllegalArgumentException(
206+
String.format(
207+
"Expected the field `audiences` to be an array in the JSON string but"
208+
+ " got `%s`",
209+
jsonObj.get("audiences").toString()));
210+
}
211+
212+
JsonArray jsonArrayaudiences = jsonObj.getAsJsonArray("audiences");
213+
// validate the required field `audiences` (array)
214+
for (int i = 0; i < jsonArrayaudiences.size(); i++) {
215+
AudienceSummary.validateJsonElement(jsonArrayaudiences.get(i));
216+
}
217+
;
218+
// validate the required field `pagination`
219+
PaginationOutput.validateJsonElement(jsonObj.get("pagination"));
220+
}
221+
222+
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
223+
@SuppressWarnings("unchecked")
224+
@Override
225+
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
226+
if (!ListAudienceConsumersFromSpaceAndAudienceOutput.class.isAssignableFrom(
227+
type.getRawType())) {
228+
return null; // this class only serializes
229+
// 'ListAudienceConsumersFromSpaceAndAudienceOutput' and its subtypes
230+
}
231+
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
232+
final TypeAdapter<ListAudienceConsumersFromSpaceAndAudienceOutput> thisAdapter =
233+
gson.getDelegateAdapter(
234+
this,
235+
TypeToken.get(ListAudienceConsumersFromSpaceAndAudienceOutput.class));
236+
237+
return (TypeAdapter<T>)
238+
new TypeAdapter<ListAudienceConsumersFromSpaceAndAudienceOutput>() {
239+
@Override
240+
public void write(
241+
JsonWriter out,
242+
ListAudienceConsumersFromSpaceAndAudienceOutput value)
243+
throws IOException {
244+
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
245+
elementAdapter.write(out, obj);
246+
}
247+
248+
@Override
249+
public ListAudienceConsumersFromSpaceAndAudienceOutput read(JsonReader in)
250+
throws IOException {
251+
JsonElement jsonElement = elementAdapter.read(in);
252+
validateJsonElement(jsonElement);
253+
return thisAdapter.fromJsonTree(jsonElement);
254+
}
255+
}.nullSafe();
256+
}
257+
}
258+
259+
/**
260+
* Create an instance of ListAudienceConsumersFromSpaceAndAudienceOutput given an JSON string
261+
*
262+
* @param jsonString JSON string
263+
* @return An instance of ListAudienceConsumersFromSpaceAndAudienceOutput
264+
* @throws IOException if the JSON string is invalid with respect to
265+
* ListAudienceConsumersFromSpaceAndAudienceOutput
266+
*/
267+
public static ListAudienceConsumersFromSpaceAndAudienceOutput fromJson(String jsonString)
268+
throws IOException {
269+
return JSON.getGson()
270+
.fromJson(jsonString, ListAudienceConsumersFromSpaceAndAudienceOutput.class);
271+
}
272+
273+
/**
274+
* Convert an instance of ListAudienceConsumersFromSpaceAndAudienceOutput to an JSON string
275+
*
276+
* @return JSON string
277+
*/
278+
public String toJson() {
279+
return JSON.getGson().toJson(this);
280+
}
281+
}

0 commit comments

Comments
 (0)
Please sign in to comment.