From bd560424b46347be567e4b5c34b5345cd6c27859 Mon Sep 17 00:00:00 2001 From: APIs and Common Services team Date: Mon, 9 Dec 2024 20:25:35 +0000 Subject: [PATCH] Automated SDK update This updates the SDK from internal repo commit segmentio/public-api@f3f82ca1. --- README.md | 8 +- docs/DbtApi.md | 82 +++++ pom.xml | 2 +- .../java/com/segment/publicapi/ApiClient.java | 2 +- .../com/segment/publicapi/Configuration.java | 2 +- src/main/java/com/segment/publicapi/JSON.java | 11 + .../com/segment/publicapi/api/DbtApi.java | 245 +++++++++++++++ .../CreateDbtModelSyncTrigger200Response.java | 203 +++++++++++++ .../CreateDbtModelSyncTriggerInput.java | 213 +++++++++++++ .../CreateDbtModelSyncTriggerOutput.java | 212 +++++++++++++ .../publicapi/models/DbtModelSyncTrigger.java | 279 ++++++++++++++++++ 11 files changed, 1252 insertions(+), 7 deletions(-) create mode 100644 docs/DbtApi.md create mode 100644 src/main/java/com/segment/publicapi/api/DbtApi.java create mode 100644 src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTrigger200Response.java create mode 100644 src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerInput.java create mode 100644 src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerOutput.java create mode 100644 src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java diff --git a/README.md b/README.md index 4e6c4c35..da6f8457 100644 --- a/README.md +++ b/README.md @@ -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.1.0 +Latest API and SDK version: 57.2.0 ## Requirements @@ -28,7 +28,7 @@ Add this dependency to your project's POM: com.segment.publicapi segment-publicapi - 57.1.0 + 57.2.0 compile ``` @@ -44,7 +44,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "com.segment.publicapi:segment-publicapi:57.1.0" + implementation "com.segment.publicapi:segment-publicapi:57.2.0" } ``` @@ -58,7 +58,7 @@ mvn clean package Then manually install the following JARs: -* `target/segment-publicapi-57.1.0.jar` +* `target/segment-publicapi-57.2.0.jar` * `target/lib/*.jar` You are now ready to start making calls to Public API! diff --git a/docs/DbtApi.md b/docs/DbtApi.md new file mode 100644 index 00000000..08513d9f --- /dev/null +++ b/docs/DbtApi.md @@ -0,0 +1,82 @@ +# DbtApi + +All URIs are relative to *https://api.segmentapis.com* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createDbtModelSyncTrigger**](DbtApi.md#createDbtModelSyncTrigger) | **POST** /dbt-model-syncs/trigger | Create Dbt Model Sync Trigger | + + + +## Operation: createDbtModelSyncTrigger + +> CreateDbtModelSyncTrigger200Response createDbtModelSyncTrigger(createDbtModelSyncTriggerInput) + +Create Dbt Model Sync Trigger + +Creates a trigger for a new dbt model sync for a Source. The rate limit for this endpoint is 10 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. + +### Example + +```java +// Import classes: +import com.segment.publicapi.ApiClient; +import com.segment.publicapi.ApiException; +import com.segment.publicapi.Configuration; +import com.segment.publicapi.auth.*; +import com.segment.publicapi.models.*; +import com.segment.publicapi.api.DbtApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + + // Configure HTTP bearer authorization: token + HttpBearerAuth token = (HttpBearerAuth) defaultClient.getAuthentication("token"); + token.setBearerToken("BEARER TOKEN"); + + DbtApi apiInstance = new DbtApi(defaultClient); + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput = new CreateDbtModelSyncTriggerInput(); // CreateDbtModelSyncTriggerInput | + try { + CreateDbtModelSyncTrigger200Response result = apiInstance.createDbtModelSyncTrigger(createDbtModelSyncTriggerInput); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DbtApi#createDbtModelSyncTrigger"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **createDbtModelSyncTriggerInput** | [**CreateDbtModelSyncTriggerInput**](CreateDbtModelSyncTriggerInput.md)| | | + +### Return type + +[**CreateDbtModelSyncTrigger200Response**](CreateDbtModelSyncTrigger200Response.md) + +### Authorization + +[token](../README.md#token) + +### HTTP request headers + +- **Content-Type**: application/vnd.segment.v1beta+json +- **Accept**: application/vnd.segment.v1beta+json, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **404** | Resource not found | - | +| **422** | Validation failure | - | +| **429** | Too many requests | - | + diff --git a/pom.xml b/pom.xml index 99143e87..7495a21d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ segment-publicapi jar segment-publicapi - 57.1.0 + 57.2.0 https://segment.com/docs/api/public-api/ Segment Public API diff --git a/src/main/java/com/segment/publicapi/ApiClient.java b/src/main/java/com/segment/publicapi/ApiClient.java index 24b2c438..f40f1146 100644 --- a/src/main/java/com/segment/publicapi/ApiClient.java +++ b/src/main/java/com/segment/publicapi/ApiClient.java @@ -123,7 +123,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("Public API SDK 57.1.0 (Java)"); + setUserAgent("Public API SDK 57.2.0 (Java)"); authentications = new HashMap(); } diff --git a/src/main/java/com/segment/publicapi/Configuration.java b/src/main/java/com/segment/publicapi/Configuration.java index 8f018bf6..df2f582b 100644 --- a/src/main/java/com/segment/publicapi/Configuration.java +++ b/src/main/java/com/segment/publicapi/Configuration.java @@ -12,7 +12,7 @@ package com.segment.publicapi; public class Configuration { - public static final String VERSION = "57.1.0"; + public static final String VERSION = "57.2.0"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/segment/publicapi/JSON.java b/src/main/java/com/segment/publicapi/JSON.java index e46ae2cf..20c61990 100644 --- a/src/main/java/com/segment/publicapi/JSON.java +++ b/src/main/java/com/segment/publicapi/JSON.java @@ -232,6 +232,15 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new com.segment.publicapi.models.CreateComputedTraitAlphaOutput .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.segment.publicapi.models.CreateDbtModelSyncTrigger200Response + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.segment.publicapi.models.CreateDbtModelSyncTriggerInput + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.segment.publicapi.models.CreateDbtModelSyncTriggerOutput + .CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new com.segment.publicapi.models.CreateDestination200Response .CustomTypeAdapterFactory()); @@ -427,6 +436,8 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new com.segment.publicapi.models.CreateWriteKeyForSourceAlphaOutput .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.segment.publicapi.models.DbtModelSyncTrigger.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new com.segment.publicapi.models.DeleteDestination200Response .CustomTypeAdapterFactory()); diff --git a/src/main/java/com/segment/publicapi/api/DbtApi.java b/src/main/java/com/segment/publicapi/api/DbtApi.java new file mode 100644 index 00000000..37dc5d6a --- /dev/null +++ b/src/main/java/com/segment/publicapi/api/DbtApi.java @@ -0,0 +1,245 @@ +/* + * Segment Public API + * 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. + * + * Contact: friends@segment.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.segment.publicapi.api; + +import com.google.gson.reflect.TypeToken; +import com.segment.publicapi.ApiCallback; +import com.segment.publicapi.ApiClient; +import com.segment.publicapi.ApiException; +import com.segment.publicapi.ApiResponse; +import com.segment.publicapi.Configuration; +import com.segment.publicapi.Pair; +import com.segment.publicapi.models.CreateDbtModelSyncTrigger200Response; +import com.segment.publicapi.models.CreateDbtModelSyncTriggerInput; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DbtApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public DbtApi() { + this(Configuration.getDefaultApiClient()); + } + + public DbtApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createDbtModelSyncTrigger + * + * @param createDbtModelSyncTriggerInput (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
404 Resource not found -
422 Validation failure -
429 Too many requests -
+ */ + public okhttp3.Call createDbtModelSyncTriggerCall( + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = createDbtModelSyncTriggerInput; + + // create path and map variables + String localVarPath = "/dbt-model-syncs/trigger"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/vnd.segment.v1beta+json", "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/vnd.segment.v1beta+json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {"token"}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createDbtModelSyncTriggerValidateBeforeCall( + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'createDbtModelSyncTriggerInput' is set + if (createDbtModelSyncTriggerInput == null) { + throw new ApiException( + "Missing the required parameter 'createDbtModelSyncTriggerInput' when calling" + + " createDbtModelSyncTrigger(Async)"); + } + + return createDbtModelSyncTriggerCall(createDbtModelSyncTriggerInput, _callback); + } + + /** + * Create Dbt Model Sync Trigger Creates a trigger for a new dbt model sync for a Source. The + * rate limit for this endpoint is 10 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. + * + * @param createDbtModelSyncTriggerInput (required) + * @return CreateDbtModelSyncTrigger200Response + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
404 Resource not found -
422 Validation failure -
429 Too many requests -
+ */ + public CreateDbtModelSyncTrigger200Response createDbtModelSyncTrigger( + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput) throws ApiException { + ApiResponse localVarResp = + createDbtModelSyncTriggerWithHttpInfo(createDbtModelSyncTriggerInput); + return localVarResp.getData(); + } + + /** + * Create Dbt Model Sync Trigger Creates a trigger for a new dbt model sync for a Source. The + * rate limit for this endpoint is 10 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. + * + * @param createDbtModelSyncTriggerInput (required) + * @return ApiResponse<CreateDbtModelSyncTrigger200Response> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
404 Resource not found -
422 Validation failure -
429 Too many requests -
+ */ + public ApiResponse createDbtModelSyncTriggerWithHttpInfo( + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput) throws ApiException { + okhttp3.Call localVarCall = + createDbtModelSyncTriggerValidateBeforeCall(createDbtModelSyncTriggerInput, null); + Type localVarReturnType = + new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Dbt Model Sync Trigger (asynchronously) Creates a trigger for a new dbt model sync for + * a Source. The rate limit for this endpoint is 10 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. + * + * @param createDbtModelSyncTriggerInput (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
404 Resource not found -
422 Validation failure -
429 Too many requests -
+ */ + public okhttp3.Call createDbtModelSyncTriggerAsync( + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createDbtModelSyncTriggerValidateBeforeCall( + createDbtModelSyncTriggerInput, _callback); + Type localVarReturnType = + new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTrigger200Response.java b/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTrigger200Response.java new file mode 100644 index 00000000..099dc651 --- /dev/null +++ b/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTrigger200Response.java @@ -0,0 +1,203 @@ +/* + * Segment Public API + * 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. + * + * Contact: friends@segment.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.segment.publicapi.models; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.segment.publicapi.JSON; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** CreateDbtModelSyncTrigger200Response */ +public class CreateDbtModelSyncTrigger200Response { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + private CreateDbtModelSyncTriggerOutput data; + + public CreateDbtModelSyncTrigger200Response() {} + + public CreateDbtModelSyncTrigger200Response data(CreateDbtModelSyncTriggerOutput data) { + + this.data = data; + return this; + } + + /** + * Get data + * + * @return data + */ + @javax.annotation.Nullable + public CreateDbtModelSyncTriggerOutput getData() { + return data; + } + + public void setData(CreateDbtModelSyncTriggerOutput data) { + this.data = data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateDbtModelSyncTrigger200Response createDbtModelSyncTrigger200Response = + (CreateDbtModelSyncTrigger200Response) o; + return Objects.equals(this.data, createDbtModelSyncTrigger200Response.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateDbtModelSyncTrigger200Response {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("data"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * CreateDbtModelSyncTrigger200Response + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateDbtModelSyncTrigger200Response.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateDbtModelSyncTrigger200Response" + + " is not found in the empty JSON string", + CreateDbtModelSyncTrigger200Response.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateDbtModelSyncTrigger200Response.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `CreateDbtModelSyncTrigger200Response` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `data` + if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { + CreateDbtModelSyncTriggerOutput.validateJsonElement(jsonObj.get("data")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateDbtModelSyncTrigger200Response.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateDbtModelSyncTrigger200Response' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateDbtModelSyncTrigger200Response.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, CreateDbtModelSyncTrigger200Response value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateDbtModelSyncTrigger200Response read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateDbtModelSyncTrigger200Response given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateDbtModelSyncTrigger200Response + * @throws IOException if the JSON string is invalid with respect to + * CreateDbtModelSyncTrigger200Response + */ + public static CreateDbtModelSyncTrigger200Response fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, CreateDbtModelSyncTrigger200Response.class); + } + + /** + * Convert an instance of CreateDbtModelSyncTrigger200Response to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerInput.java b/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerInput.java new file mode 100644 index 00000000..cd58fe70 --- /dev/null +++ b/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerInput.java @@ -0,0 +1,213 @@ +/* + * Segment Public API + * 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. + * + * Contact: friends@segment.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.segment.publicapi.models; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.segment.publicapi.JSON; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Input for the createDbtModelSyncTriggerBySourceId endpoint. */ +public class CreateDbtModelSyncTriggerInput { + public static final String SERIALIZED_NAME_SOURCE_ID = "sourceId"; + + @SerializedName(SERIALIZED_NAME_SOURCE_ID) + private String sourceId; + + public CreateDbtModelSyncTriggerInput() {} + + public CreateDbtModelSyncTriggerInput sourceId(String sourceId) { + + this.sourceId = sourceId; + return this; + } + + /** + * The Source id to trigger a dbt model sync. + * + * @return sourceId + */ + @javax.annotation.Nonnull + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateDbtModelSyncTriggerInput createDbtModelSyncTriggerInput = + (CreateDbtModelSyncTriggerInput) o; + return Objects.equals(this.sourceId, createDbtModelSyncTriggerInput.sourceId); + } + + @Override + public int hashCode() { + return Objects.hash(sourceId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateDbtModelSyncTriggerInput {\n"); + sb.append(" sourceId: ").append(toIndentedString(sourceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sourceId"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("sourceId"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * CreateDbtModelSyncTriggerInput + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateDbtModelSyncTriggerInput.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateDbtModelSyncTriggerInput is not" + + " found in the empty JSON string", + CreateDbtModelSyncTriggerInput.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateDbtModelSyncTriggerInput.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `CreateDbtModelSyncTriggerInput` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateDbtModelSyncTriggerInput.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("sourceId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `sourceId` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("sourceId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateDbtModelSyncTriggerInput.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateDbtModelSyncTriggerInput' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateDbtModelSyncTriggerInput.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateDbtModelSyncTriggerInput value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateDbtModelSyncTriggerInput read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateDbtModelSyncTriggerInput given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateDbtModelSyncTriggerInput + * @throws IOException if the JSON string is invalid with respect to + * CreateDbtModelSyncTriggerInput + */ + public static CreateDbtModelSyncTriggerInput fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateDbtModelSyncTriggerInput.class); + } + + /** + * Convert an instance of CreateDbtModelSyncTriggerInput to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerOutput.java b/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerOutput.java new file mode 100644 index 00000000..4ce68c9b --- /dev/null +++ b/src/main/java/com/segment/publicapi/models/CreateDbtModelSyncTriggerOutput.java @@ -0,0 +1,212 @@ +/* + * Segment Public API + * 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. + * + * Contact: friends@segment.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.segment.publicapi.models; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.segment.publicapi.JSON; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Output for the createDbtModelSyncTriggerBySourceId endpoint. */ +public class CreateDbtModelSyncTriggerOutput { + public static final String SERIALIZED_NAME_DBT_MODEL_SYNC_TRIGGER = "dbtModelSyncTrigger"; + + @SerializedName(SERIALIZED_NAME_DBT_MODEL_SYNC_TRIGGER) + private DbtModelSyncTrigger dbtModelSyncTrigger; + + public CreateDbtModelSyncTriggerOutput() {} + + public CreateDbtModelSyncTriggerOutput dbtModelSyncTrigger( + DbtModelSyncTrigger dbtModelSyncTrigger) { + + this.dbtModelSyncTrigger = dbtModelSyncTrigger; + return this; + } + + /** + * Get dbtModelSyncTrigger + * + * @return dbtModelSyncTrigger + */ + @javax.annotation.Nonnull + public DbtModelSyncTrigger getDbtModelSyncTrigger() { + return dbtModelSyncTrigger; + } + + public void setDbtModelSyncTrigger(DbtModelSyncTrigger dbtModelSyncTrigger) { + this.dbtModelSyncTrigger = dbtModelSyncTrigger; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateDbtModelSyncTriggerOutput createDbtModelSyncTriggerOutput = + (CreateDbtModelSyncTriggerOutput) o; + return Objects.equals( + this.dbtModelSyncTrigger, createDbtModelSyncTriggerOutput.dbtModelSyncTrigger); + } + + @Override + public int hashCode() { + return Objects.hash(dbtModelSyncTrigger); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateDbtModelSyncTriggerOutput {\n"); + sb.append(" dbtModelSyncTrigger: ") + .append(toIndentedString(dbtModelSyncTrigger)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("dbtModelSyncTrigger"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("dbtModelSyncTrigger"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * CreateDbtModelSyncTriggerOutput + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateDbtModelSyncTriggerOutput.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateDbtModelSyncTriggerOutput is not" + + " found in the empty JSON string", + CreateDbtModelSyncTriggerOutput.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateDbtModelSyncTriggerOutput.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `CreateDbtModelSyncTriggerOutput` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateDbtModelSyncTriggerOutput.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `dbtModelSyncTrigger` + DbtModelSyncTrigger.validateJsonElement(jsonObj.get("dbtModelSyncTrigger")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateDbtModelSyncTriggerOutput.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateDbtModelSyncTriggerOutput' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateDbtModelSyncTriggerOutput.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateDbtModelSyncTriggerOutput value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateDbtModelSyncTriggerOutput read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateDbtModelSyncTriggerOutput given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateDbtModelSyncTriggerOutput + * @throws IOException if the JSON string is invalid with respect to + * CreateDbtModelSyncTriggerOutput + */ + public static CreateDbtModelSyncTriggerOutput fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateDbtModelSyncTriggerOutput.class); + } + + /** + * Convert an instance of CreateDbtModelSyncTriggerOutput to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java b/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java new file mode 100644 index 00000000..8d8555e5 --- /dev/null +++ b/src/main/java/com/segment/publicapi/models/DbtModelSyncTrigger.java @@ -0,0 +1,279 @@ +/* + * Segment Public API + * 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. + * + * Contact: friends@segment.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.segment.publicapi.models; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.segment.publicapi.JSON; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Defines the DBT Model Sync Trigger. */ +public class DbtModelSyncTrigger { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_SOURCE_ID = "sourceId"; + + @SerializedName(SERIALIZED_NAME_SOURCE_ID) + private String sourceId; + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + private String status; + + public DbtModelSyncTrigger() {} + + public DbtModelSyncTrigger id(String id) { + + this.id = id; + return this; + } + + /** + * The id of the DBT Model Sync. + * + * @return id + */ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public DbtModelSyncTrigger sourceId(String sourceId) { + + this.sourceId = sourceId; + return this; + } + + /** + * The Source id that was triggered. + * + * @return sourceId + */ + @javax.annotation.Nullable + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public DbtModelSyncTrigger status(String status) { + + this.status = status; + return this; + } + + /** + * The status of the trigger. + * + * @return status + */ + @javax.annotation.Nonnull + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DbtModelSyncTrigger dbtModelSyncTrigger = (DbtModelSyncTrigger) o; + return Objects.equals(this.id, dbtModelSyncTrigger.id) + && Objects.equals(this.sourceId, dbtModelSyncTrigger.sourceId) + && Objects.equals(this.status, dbtModelSyncTrigger.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, sourceId, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DbtModelSyncTrigger {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" sourceId: ").append(toIndentedString(sourceId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("sourceId"); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("status"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to DbtModelSyncTrigger + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!DbtModelSyncTrigger.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in DbtModelSyncTrigger is not found in" + + " the empty JSON string", + DbtModelSyncTrigger.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!DbtModelSyncTrigger.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `DbtModelSyncTrigger` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DbtModelSyncTrigger.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("sourceId") != null && !jsonObj.get("sourceId").isJsonNull()) + && !jsonObj.get("sourceId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `sourceId` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("sourceId").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `status` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DbtModelSyncTrigger.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DbtModelSyncTrigger' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(DbtModelSyncTrigger.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, DbtModelSyncTrigger value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public DbtModelSyncTrigger read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of DbtModelSyncTrigger given an JSON string + * + * @param jsonString JSON string + * @return An instance of DbtModelSyncTrigger + * @throws IOException if the JSON string is invalid with respect to DbtModelSyncTrigger + */ + public static DbtModelSyncTrigger fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DbtModelSyncTrigger.class); + } + + /** + * Convert an instance of DbtModelSyncTrigger to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +}