From 2e8ea69b9a75c5b3db0f7ba8ee55525bc14a6e1e Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:55:24 +0000 Subject: [PATCH 1/2] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-java-sdk: 4.11.1 --- .fern/metadata.json | 10 +- build.gradle | 46 +- reference.md | 56 +- .../schematic/api/AsyncRawBaseSchematic.java | 14 + .../com/schematic/api/RawBaseSchematic.java | 13 + .../com/schematic/api/core/ClientOptions.java | 4 +- .../api/core/DateTimeDeserializer.java | 15 +- .../schematic/api/core/RequestOptions.java | 16 + .../schematic/api/core/RetryInterceptor.java | 33 +- .../AsyncRawAccesstokensClient.java | 13 + .../accesstokens/RawAccesstokensClient.java | 12 + .../accounts/AsyncRawAccountsClient.java | 229 ++++++ .../resources/accounts/RawAccountsClient.java | 210 ++++++ .../types/CountAccountMembersResponse.java | 1 - .../accounts/types/CountApiKeysResponse.java | 1 - .../types/CountAuditLogsResponse.java | 1 - .../types/ListAccountMembersResponse.java | 1 - .../accounts/types/ListApiKeysResponse.java | 1 - .../accounts/types/ListAuditLogsResponse.java | 1 - .../types/ListEnvironmentsResponse.java | 1 - .../billing/AsyncRawBillingClient.java | 289 +++++++ .../resources/billing/RawBillingClient.java | 265 +++++++ .../requests/CreateInvoiceRequestBody.java | 64 ++ .../types/CountBillingProductsResponse.java | 1 - .../billing/types/CountCustomersResponse.java | 1 - .../types/ListBillingPricesResponse.java | 1 - .../ListBillingProductPricesResponse.java | 1 - .../types/ListBillingProductsResponse.java | 1 - .../billing/types/ListCouponsResponse.java | 1 - ...istCustomersWithSubscriptionsResponse.java | 1 - .../billing/types/ListInvoicesResponse.java | 1 - .../billing/types/ListMetersResponse.java | 1 - .../types/ListPaymentMethodsResponse.java | 1 - .../checkout/AsyncRawCheckoutClient.java | 85 +++ .../resources/checkout/RawCheckoutClient.java | 78 ++ .../companies/AsyncRawCompaniesClient.java | 457 +++++++++++ .../companies/RawCompaniesClient.java | 419 +++++++++++ .../types/CountCompaniesResponse.java | 1 - .../CountEntityKeyDefinitionsResponse.java | 1 - .../CountEntityTraitDefinitionsResponse.java | 1 - .../types/CountPlanTraitsResponse.java | 1 - .../companies/types/CountUsersResponse.java | 1 - .../types/DeleteCompanyResponse.java | 1 - .../GetActiveCompanySubscriptionResponse.java | 1 - ...llingEntityChildSubscriptionsResponse.java | 1 - .../GetCompanyBillingEntityResponse.java | 1 - .../types/GetEntityTraitValuesResponse.java | 1 - .../types/ListCompaniesResponse.java | 1 - .../types/ListCompanyMembershipsResponse.java | 1 - .../ListEntityKeyDefinitionsResponse.java | 1 - .../ListEntityTraitDefinitionsResponse.java | 1 - .../types/ListPlanChangesResponse.java | 1 - .../types/ListPlanTraitsResponse.java | 1 - .../companies/types/ListUsersResponse.java | 1 - .../types/LookupCompanyResponse.java | 1 - .../companies/types/LookupUserResponse.java | 1 - .../components/AsyncRawComponentsClient.java | 85 +++ .../components/RawComponentsClient.java | 78 ++ .../types/CountComponentsResponse.java | 1 - .../types/ListComponentsResponse.java | 1 - .../types/PreviewComponentDataResponse.java | 1 - .../AsyncRawComponentspublicClient.java | 13 + .../RawComponentspublicClient.java | 12 + .../credits/AsyncRawCreditsClient.java | 361 +++++++++ .../resources/credits/RawCreditsClient.java | 331 ++++++++ .../CountBillingCreditsGrantsResponse.java | 1 - .../types/CountBillingCreditsResponse.java | 1 - .../CountBillingPlanCreditGrantsResponse.java | 1 - .../types/CountCompanyGrantsResponse.java | 1 - .../types/CountCreditBundlesResponse.java | 1 - .../types/CountCreditEventLedgerResponse.java | 1 - .../DeleteBillingPlanCreditGrantResponse.java | 1 - .../types/ListBillingCreditsResponse.java | 1 - .../ListBillingPlanCreditGrantsResponse.java | 1 - .../ListCompanyCreditBalancesResponse.java | 1 - .../types/ListCompanyGrantsResponse.java | 1 - .../types/ListCreditBundlesResponse.java | 1 - .../types/ListCreditEventLedgerResponse.java | 1 - .../types/ListGrantsForCreditResponse.java | 1 - .../AsyncRawDataexportsClient.java | 25 + .../dataexports/RawDataexportsClient.java | 23 + .../AsyncRawEntitlementsClient.java | 265 +++++++ .../entitlements/RawEntitlementsClient.java | 243 ++++++ ...llingLinkedPlanEntitlementRequestBody.java | 33 + .../CreatePlanEntitlementRequestBody.java | 33 + .../UpdatePlanEntitlementRequestBody.java | 33 + .../types/CountCompanyOverridesResponse.java | 1 - .../types/CountFeatureCompaniesResponse.java | 1 - .../types/CountFeatureUsageResponse.java | 1 - .../types/CountFeatureUsersResponse.java | 1 - .../types/CountPlanEntitlementsResponse.java | 1 - .../GetFeatureUsageByCompanyResponse.java | 1 - .../GetFeatureUsageTimeSeriesResponse.java | 1 - .../types/ListCompanyOverridesResponse.java | 1 - .../types/ListFeatureCompaniesResponse.java | 1 - .../types/ListFeatureUsageResponse.java | 1 - .../types/ListFeatureUsersResponse.java | 1 - .../types/ListPlanEntitlementsResponse.java | 1 - .../events/AsyncRawEventsClient.java | 73 ++ .../api/resources/events/RawEventsClient.java | 67 ++ .../types/GetEventSummariesResponse.java | 1 - .../events/types/ListEventsResponse.java | 1 - .../features/AsyncRawFeaturesClient.java | 205 +++++ .../resources/features/RawFeaturesClient.java | 188 +++++ .../features/types/CountFeaturesResponse.java | 1 - .../features/types/CountFlagsResponse.java | 1 - .../features/types/ListFeaturesResponse.java | 1 - .../features/types/ListFlagsResponse.java | 1 - .../insights/AsyncRawInsightsClient.java | 73 ++ .../resources/insights/RawInsightsClient.java | 67 ++ .../insights/types/GetActivityResponse.java | 1 - ...ronmentFeatureUsageTimeSeriesResponse.java | 1 - ...vironmentTraitUsageTimeSeriesResponse.java | 1 - .../insights/types/GetPlanGrowthResponse.java | 1 - .../types/GetTopFeaturesByUsageResponse.java | 1 - .../AsyncRawIntegrationsapiClient.java | 109 +++ .../RawIntegrationsapiClient.java | 100 +++ .../types/ListIntegrationsResponse.java | 1 - .../planbundle/AsyncRawPlanbundleClient.java | 37 + .../planbundle/RawPlanbundleClient.java | 34 + .../requests/CreatePlanBundleRequestBody.java | 31 +- .../requests/UpdatePlanBundleRequestBody.java | 32 +- .../plangroups/AsyncRawPlangroupsClient.java | 37 + .../plangroups/RawPlangroupsClient.java | 34 + .../types/GetPlanGroupResponse.java | 1 - .../AsyncRawPlanmigrationsClient.java | 97 +++ .../RawPlanmigrationsClient.java | 89 +++ .../types/CountCompanyMigrationsResponse.java | 1 - .../types/CountMigrationsResponse.java | 1 - .../types/ListCompanyMigrationsResponse.java | 1 - .../types/ListMigrationsResponse.java | 1 - .../resources/plans/AsyncRawPlansClient.java | 217 ++++++ .../api/resources/plans/RawPlansClient.java | 199 +++++ ...ntBillingProductMatchCompaniesRequest.java | 1 - ...stBillingProductMatchCompaniesRequest.java | 1 - ...tBillingProductMatchCompaniesResponse.java | 1 - .../plans/types/CountPlansResponse.java | 1 - .../types/DeletePlanVersionResponse.java | 1 - .../plans/types/GetPlanResponse.java | 1 - ...tBillingProductMatchCompaniesResponse.java | 1 - .../types/ListCustomPlanBillingsResponse.java | 1 - .../plans/types/ListPlanIssuesResponse.java | 1 - .../plans/types/ListPlansResponse.java | 1 - .../AsyncRawScheduledcheckoutClient.java | 49 ++ .../RawScheduledcheckoutClient.java | 45 ++ .../types/ListScheduledCheckoutsResponse.java | 1 - .../webhooks/AsyncRawWebhooksClient.java | 121 +++ .../resources/webhooks/RawWebhooksClient.java | 111 +++ .../types/CountWebhookEventsResponse.java | 1 - .../webhooks/types/CountWebhooksResponse.java | 1 - .../types/ListWebhookEventsResponse.java | 1 - .../webhooks/types/ListWebhooksResponse.java | 1 - .../api/types/AccountMemberPermission.java | 11 + .../com/schematic/api/types/ApiError.java | 1 - .../BillingCreditGrantZeroedOutReason.java | 22 + .../BillingPlanCreditGrantResetCadence.java | 22 + .../BillingPlanCreditGrantResponseData.java | 6 - .../api/types/CheckFlagResponseData.java | 3 - .../api/types/CompanyCreditBalance.java | 3 - .../api/types/CompanyPlanCreditGrantView.java | 2 - .../types/CompanyPlanDetailResponseData.java | 1 - .../api/types/CreateEventRequestBody.java | 1 - .../com/schematic/api/types/EventBody.java | 19 + .../api/types/EventBodyFlagCheck.java | 3 - .../api/types/EventBodyInference.java | 712 ++++++++++++++++++ .../schematic/api/types/EventBodyTrack.java | 1 - .../com/schematic/api/types/EventType.java | 10 + .../api/types/FeatureCompanyResponseData.java | 2 - .../types/FeatureCompanyUserResponseData.java | 2 - .../api/types/FeatureEntitlement.java | 3 - .../api/types/FeatureUsageResponseData.java | 2 - .../types/IntegrationsListResponseData.java | 42 +- .../api/types/InvoiceRequestBody.java | 64 ++ .../api/types/InvoiceResponseData.java | 62 +- .../api/types/MetronomeIntegrationConfig.java | 49 +- .../api/types/PlanBundleResponseData.java | 31 +- .../api/types/PlanChangeResponseData.java | 1 - .../api/types/PlanCreditGrantView.java | 2 - .../api/types/PlanDetailResponseData.java | 1 - .../types/PlanEntitlementResponseData.java | 49 +- .../PlanGroupPlanDetailResponseData.java | 1 - .../api/types/PlanViewPublicResponseData.java | 1 - .../types/RulesengineFeatureEntitlement.java | 3 - .../api/types/StripeIntegrationConfig.java | 2 - .../api/types/UpsertTraitRequestBody.java | 1 - .../api/types/WarningTierRequestBody.java | 140 ++++ .../api/types/WarningTierResponseData.java | 162 ++++ .../api/UndiscriminatedUnionTest.java | 9 + 188 files changed, 7140 insertions(+), 281 deletions(-) create mode 100644 src/main/java/com/schematic/api/types/EventBodyInference.java create mode 100644 src/main/java/com/schematic/api/types/WarningTierRequestBody.java create mode 100644 src/main/java/com/schematic/api/types/WarningTierResponseData.java diff --git a/.fern/metadata.json b/.fern/metadata.json index 866db587..1dc7ebde 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { - "cliVersion": "5.6.0", + "cliVersion": "5.50.0", "generatorName": "fernapi/fern-java-sdk", - "generatorVersion": "4.10.7", + "generatorVersion": "4.11.1", "generatorConfig": { "client-class-name": "BaseSchematic", "generate-unknown-as-json-node": true, @@ -14,10 +14,10 @@ "implementation redis.clients:jedis:5.2.0" ] }, - "originGitCommit": "1e5d567c7baf29c75ed5e08c9dd30b7e83de8e27", + "originGitCommit": "19cafdf92ab056ef6ba803bf1e352b0422a8ec45", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "1.5.0", + "requestedVersion": "1.5.1", "ciProvider": "github", - "sdkVersion": "1.5.0" + "sdkVersion": "1.5.1" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5cb80625..aaef1575 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,19 @@ +buildscript { + repositories { + gradlePluginPortal() + } + dependencies { + if (JavaVersion.current().isJava11Compatible()) { + classpath 'cl.franciscosolis:SonatypeCentralUpload:1.0.3' + } + } +} + plugins { id 'java-library' id 'maven-publish' id 'com.diffplug.spotless' version '6.11.0' id 'signing' - id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3' } repositories { @@ -52,7 +62,7 @@ java { group = 'com.schematichq' -version = '1.5.0' +version = '1.5.1' jar { dependsOn(":generatePomFileForMavenPublication") @@ -83,7 +93,7 @@ publishing { maven(MavenPublication) { groupId = 'com.schematichq' artifactId = 'schematic-java' - version = '1.5.0' + version = '1.5.1' from components.java pom { name = 'Schematic' @@ -110,19 +120,25 @@ publishing { } } -sonatypeCentralUpload { - username = "$System.env.MAVEN_USERNAME" - password = "$System.env.MAVEN_PASSWORD" +if (JavaVersion.current().isJava11Compatible()) { + apply plugin: 'cl.franciscosolis.sonatype-central-upload' - archives = files( - "$buildDir/libs/schematic-java-" + version + ".jar", - "$buildDir/libs/schematic-java-" + version + "-sources.jar", - "$buildDir/libs/schematic-java-" + version + "-javadoc.jar" - ) + sonatypeCentralUpload { + username = "$System.env.MAVEN_USERNAME" + password = "$System.env.MAVEN_PASSWORD" - pom = file("$buildDir/publications/maven/pom-default.xml") - signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" - signingKeyPassphrase = "$System.env.MAVEN_SIGNATURE_PASSWORD" + archives = files( + "$buildDir/libs/schematic-java-" + version + ".jar", + "$buildDir/libs/schematic-java-" + version + "-sources.jar", + "$buildDir/libs/schematic-java-" + version + "-javadoc.jar" + ) + + pom = file("$buildDir/publications/maven/pom-default.xml") + signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" + signingKeyPassphrase = "$System.env.MAVEN_SIGNATURE_PASSWORD" + } + + sonatypeCentralUpload.dependsOn build } signing { @@ -132,5 +148,3 @@ signing { useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) sign publishing.publications.maven } - -sonatypeCentralUpload.dependsOn build diff --git a/reference.md b/reference.md index a8fb8944..97bae759 100644 --- a/reference.md +++ b/reference.md @@ -1844,6 +1844,14 @@ client.billing().upsertInvoice(
+**endingBalance:** `Optional` + +
+
+ +
+
+ **externalId:** `Optional`
@@ -1860,6 +1868,14 @@ client.billing().upsertInvoice(
+**startingBalance:** `Optional` + +
+
+ +
+
+ **status:** `Optional`
@@ -10858,6 +10874,14 @@ client.entitlements().createPlanEntitlement(
+**warningTiers:** `Optional>` + +
+
+ +
+
+ **yearlyMeteredPriceId:** `Optional`
@@ -11184,6 +11208,14 @@ client.entitlements().updatePlanEntitlement(
+**warningTiers:** `Optional>` + +
+
+ +
+
+ **yearlyMeteredPriceId:** `Optional`
@@ -11545,6 +11577,14 @@ client.entitlements().upsertPlanEntitlementForBillingProduct(
+**warningTiers:** `Optional>` + +
+
+ +
+
+ **yearlyMeteredPriceId:** `Optional`
@@ -13799,14 +13839,6 @@ client.planbundle().createPlanBundle( **plan:** `Optional` - -
- -
-
- -**traits:** `Optional>` -
@@ -13900,14 +13932,6 @@ client.planbundle().updatePlanBundle( **planVersionId:** `Optional` - -
- -
-
- -**traits:** `Optional>` -
diff --git a/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java b/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java index 6d926ed2..35685983 100644 --- a/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java +++ b/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java @@ -3,12 +3,14 @@ */ package com.schematic.api; +import com.fasterxml.jackson.core.JsonProcessingException; import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.BaseSchematicHttpResponse; import com.schematic.api.core.ClientOptions; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -50,6 +52,15 @@ public CompletableFuture> getCreditLedger(Reques if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -64,6 +75,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/RawBaseSchematic.java b/src/main/java/com/schematic/api/RawBaseSchematic.java index 9f77bf36..4bdf2c2f 100644 --- a/src/main/java/com/schematic/api/RawBaseSchematic.java +++ b/src/main/java/com/schematic/api/RawBaseSchematic.java @@ -3,12 +3,14 @@ */ package com.schematic.api; +import com.fasterxml.jackson.core.JsonProcessingException; import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.BaseSchematicHttpResponse; import com.schematic.api.core.ClientOptions; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -46,6 +48,15 @@ public BaseSchematicHttpResponse getCreditLedger(RequestOptions requestOpt if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); if (response.isSuccessful()) { @@ -55,6 +66,8 @@ public BaseSchematicHttpResponse getCreditLedger(RequestOptions requestOpt Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/core/ClientOptions.java b/src/main/java/com/schematic/api/core/ClientOptions.java index 59fa6ca7..15e79315 100644 --- a/src/main/java/com/schematic/api/core/ClientOptions.java +++ b/src/main/java/com/schematic/api/core/ClientOptions.java @@ -38,10 +38,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.schematichq:schematic-java/1.5.0"); + put("User-Agent", "com.schematichq:schematic-java/1.5.1"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.schematic.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.5.0"); + put("X-Fern-SDK-Version", "1.5.1"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/schematic/api/core/DateTimeDeserializer.java b/src/main/java/com/schematic/api/core/DateTimeDeserializer.java index c60a3a44..833169fb 100644 --- a/src/main/java/com/schematic/api/core/DateTimeDeserializer.java +++ b/src/main/java/com/schematic/api/core/DateTimeDeserializer.java @@ -19,7 +19,8 @@ import java.time.temporal.TemporalQueries; /** - * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. + * Custom deserializer that handles converting date-time strings into {@link OffsetDateTime} objects. + * Supports ISO 8601 format, space-separated variants, and RFC 1123 (RFC 2822) format. */ class DateTimeDeserializer extends JsonDeserializer { private static final SimpleModule MODULE; @@ -48,9 +49,15 @@ public OffsetDateTime deserialize(JsonParser parser, DeserializationContext cont try { temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest(value, OffsetDateTime::from, LocalDateTime::from); } catch (DateTimeParseException e) { - // Fall back to space-separated format (e.g. "2025-02-15 10:30:00+00:00"). - temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( - value.replace(' ', 'T'), OffsetDateTime::from, LocalDateTime::from); + try { + // Fall back to space-separated format (e.g. "2025-02-15 10:30:00+00:00"). + temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( + value.replace(' ', 'T'), OffsetDateTime::from, LocalDateTime::from); + } catch (DateTimeParseException e2) { + // Fall back to RFC 1123 format (e.g. "Thu, 07 May 2026 14:23:38 +0000"). + temporal = DateTimeFormatter.RFC_1123_DATE_TIME.parseBest( + value, OffsetDateTime::from, LocalDateTime::from); + } } if (temporal.query(TemporalQueries.offset()) == null) { diff --git a/src/main/java/com/schematic/api/core/RequestOptions.java b/src/main/java/com/schematic/api/core/RequestOptions.java index 7249e3c1..7b5afb39 100644 --- a/src/main/java/com/schematic/api/core/RequestOptions.java +++ b/src/main/java/com/schematic/api/core/RequestOptions.java @@ -16,6 +16,8 @@ public final class RequestOptions { private final TimeUnit timeoutTimeUnit; + private final Optional maxRetries; + private final Map headers; private final Map> headerSuppliers; @@ -28,6 +30,7 @@ private RequestOptions( String apiKey, Optional timeout, TimeUnit timeoutTimeUnit, + Optional maxRetries, Map headers, Map> headerSuppliers, Map queryParameters, @@ -35,6 +38,7 @@ private RequestOptions( this.apiKey = apiKey; this.timeout = timeout; this.timeoutTimeUnit = timeoutTimeUnit; + this.maxRetries = maxRetries; this.headers = headers; this.headerSuppliers = headerSuppliers; this.queryParameters = queryParameters; @@ -49,6 +53,10 @@ public TimeUnit getTimeoutTimeUnit() { return timeoutTimeUnit; } + public Optional getMaxRetries() { + return maxRetries; + } + public Map getHeaders() { Map headers = new HashMap<>(); if (this.apiKey != null) { @@ -80,6 +88,8 @@ public static class Builder { private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + private Optional maxRetries = Optional.empty(); + private final Map headers = new HashMap<>(); private final Map> headerSuppliers = new HashMap<>(); @@ -104,6 +114,11 @@ public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { return this; } + public Builder maxRetries(Integer maxRetries) { + this.maxRetries = Optional.of(maxRetries); + return this; + } + public Builder addHeader(String key, String value) { this.headers.put(key, value); return this; @@ -129,6 +144,7 @@ public RequestOptions build() { apiKey, timeout, timeoutTimeUnit, + maxRetries, headers, headerSuppliers, queryParameters, diff --git a/src/main/java/com/schematic/api/core/RetryInterceptor.java b/src/main/java/com/schematic/api/core/RetryInterceptor.java index 5493606e..de9aa090 100644 --- a/src/main/java/com/schematic/api/core/RetryInterceptor.java +++ b/src/main/java/com/schematic/api/core/RetryInterceptor.java @@ -11,6 +11,7 @@ import java.util.Optional; import java.util.Random; import okhttp3.Interceptor; +import okhttp3.Request; import okhttp3.Response; public class RetryInterceptor implements Interceptor { @@ -28,17 +29,24 @@ public RetryInterceptor(int maxRetries) { @Override public Response intercept(Chain chain) throws IOException { - Response response = chain.proceed(chain.request()); + Request request = chain.request(); + int effectiveMaxRetries = resolveMaxRetries(request); + Response response = chain.proceed(request); if (shouldRetry(response.code())) { - return retryChain(response, chain); + return retryChain(response, chain, effectiveMaxRetries); } return response; } - private Response retryChain(Response response, Chain chain) throws IOException { - ExponentialBackoff backoff = new ExponentialBackoff(this.maxRetries); + private int resolveMaxRetries(Request request) { + MaxRetriesOverride override = request.tag(MaxRetriesOverride.class); + return override != null ? override.getValue() : this.maxRetries; + } + + private Response retryChain(Response response, Chain chain, int maxRetries) throws IOException { + ExponentialBackoff backoff = new ExponentialBackoff(maxRetries); Optional nextBackoff = backoff.nextBackoff(response); while (nextBackoff.isPresent()) { try { @@ -158,6 +166,23 @@ private static boolean shouldRetry(int statusCode) { return statusCode == 408 || statusCode == 429 || statusCode >= 500; } + /** + * Per-request override carried on the OkHttp {@link Request} as a tag. + * When present, the interceptor uses this value instead of the client-wide + * {@code maxRetries} configured at construction time. + */ + public static final class MaxRetriesOverride { + private final int value; + + public MaxRetriesOverride(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + private final class ExponentialBackoff { private final int maxNumRetries; diff --git a/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java b/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java index 66c03805..7da5465d 100644 --- a/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java +++ b/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.MediaTypes; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -72,6 +73,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -121,6 +131,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java b/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java index 039327bf..6a8a1faa 100644 --- a/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java +++ b/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.MediaTypes; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -68,6 +69,15 @@ public BaseSchematicHttpResponse issueTempora if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -101,6 +111,8 @@ public BaseSchematicHttpResponse issueTempora Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java index 74be6fee..1fc9b4d9 100644 --- a/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java +++ b/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -116,6 +117,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -164,6 +174,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -203,6 +216,15 @@ public CompletableFuture> ge if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -245,6 +267,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -306,6 +331,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -354,6 +388,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -404,6 +441,15 @@ public CompletableFuture> listApi if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -451,6 +497,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -497,6 +546,15 @@ public CompletableFuture> create if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -544,6 +602,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -582,6 +643,15 @@ public CompletableFuture> getApiKey if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -624,6 +694,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -680,6 +753,15 @@ public CompletableFuture> update if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -727,6 +809,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -765,6 +850,15 @@ public CompletableFuture> delete if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -812,6 +906,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -863,6 +960,15 @@ public CompletableFuture> countA if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -910,6 +1016,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -984,6 +1093,15 @@ public CompletableFuture> listA if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1031,6 +1149,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1069,6 +1190,15 @@ public CompletableFuture> getAudi if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1111,6 +1241,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1185,6 +1318,15 @@ public CompletableFuture> coun if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1232,6 +1374,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1290,6 +1435,15 @@ public CompletableFuture> li if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1337,6 +1491,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1383,6 +1540,15 @@ public CompletableFuture> c if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1431,6 +1597,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1469,6 +1638,15 @@ public CompletableFuture> getE if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1511,6 +1689,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1570,6 +1751,15 @@ public CompletableFuture> u if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1618,6 +1808,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1657,6 +1850,15 @@ public CompletableFuture> d if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1705,6 +1907,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1741,6 +1946,15 @@ public CompletableFuture> quicksta if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1788,6 +2002,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1824,6 +2041,15 @@ public CompletableFuture> getWhoAmI if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1866,6 +2092,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java index f231db68..b91959d6 100644 --- a/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java +++ b/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -110,6 +111,15 @@ public BaseSchematicHttpResponse listAccountMembers( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -142,6 +152,8 @@ public BaseSchematicHttpResponse listAccountMembers( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -172,6 +184,15 @@ public BaseSchematicHttpResponse getAccountMember( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -201,6 +222,8 @@ public BaseSchematicHttpResponse getAccountMember( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -253,6 +276,15 @@ public BaseSchematicHttpResponse countAccountMember if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -285,6 +317,8 @@ public BaseSchematicHttpResponse countAccountMember Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -327,6 +361,15 @@ public BaseSchematicHttpResponse listApiKeys( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -358,6 +401,8 @@ public BaseSchematicHttpResponse listApiKeys( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -395,6 +440,15 @@ public BaseSchematicHttpResponse createApiKey( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -426,6 +480,8 @@ public BaseSchematicHttpResponse createApiKey( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -455,6 +511,15 @@ public BaseSchematicHttpResponse getApiKey(String apiKeyId, R if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -483,6 +548,8 @@ public BaseSchematicHttpResponse getApiKey(String apiKeyId, R Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -531,6 +598,15 @@ public BaseSchematicHttpResponse updateApiKey( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -562,6 +638,8 @@ public BaseSchematicHttpResponse updateApiKey( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -592,6 +670,15 @@ public BaseSchematicHttpResponse deleteApiKey( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -623,6 +710,8 @@ public BaseSchematicHttpResponse deleteApiKey( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -665,6 +754,15 @@ public BaseSchematicHttpResponse countApiKeys( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -696,6 +794,8 @@ public BaseSchematicHttpResponse countApiKeys( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -760,6 +860,15 @@ public BaseSchematicHttpResponse listAuditLogs( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -791,6 +900,8 @@ public BaseSchematicHttpResponse listAuditLogs( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -821,6 +932,15 @@ public BaseSchematicHttpResponse getAuditLog( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -849,6 +969,8 @@ public BaseSchematicHttpResponse getAuditLog( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -913,6 +1035,15 @@ public BaseSchematicHttpResponse countAuditLogs( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -945,6 +1076,8 @@ public BaseSchematicHttpResponse countAuditLogs( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -993,6 +1126,15 @@ public BaseSchematicHttpResponse listEnvironments( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1025,6 +1167,8 @@ public BaseSchematicHttpResponse listEnvironments( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1063,6 +1207,15 @@ public BaseSchematicHttpResponse createEnvironment( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1095,6 +1248,8 @@ public BaseSchematicHttpResponse createEnvironment( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1125,6 +1280,15 @@ public BaseSchematicHttpResponse getEnvironment( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1154,6 +1318,8 @@ public BaseSchematicHttpResponse getEnvironment( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1204,6 +1370,15 @@ public BaseSchematicHttpResponse updateEnvironment( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1236,6 +1411,8 @@ public BaseSchematicHttpResponse updateEnvironment( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1266,6 +1443,15 @@ public BaseSchematicHttpResponse deleteEnvironment( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1298,6 +1484,8 @@ public BaseSchematicHttpResponse deleteEnvironment( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1326,6 +1514,15 @@ public BaseSchematicHttpResponse quickstart(RequestOptions r if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1357,6 +1554,8 @@ public BaseSchematicHttpResponse quickstart(RequestOptions r Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1385,6 +1584,15 @@ public BaseSchematicHttpResponse getWhoAmI(RequestOptions req if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1413,6 +1621,8 @@ public BaseSchematicHttpResponse getWhoAmI(RequestOptions req Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountAccountMembersResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CountAccountMembersResponse.java index 049c8f94..ce7268c2 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountAccountMembersResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountAccountMembersResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java index 8426363d..226716aa 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsResponse.java index 2e05a86f..bae56b88 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountAuditLogsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListAccountMembersResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListAccountMembersResponse.java index 7b669eb7..22cb889a 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListAccountMembersResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListAccountMembersResponse.java @@ -122,7 +122,6 @@ public Builder from(ListAccountMembersResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java index e4de72a5..2695cfe2 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java @@ -120,7 +120,6 @@ public Builder from(ListApiKeysResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsResponse.java index 996fba9c..6cfe13c6 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListAuditLogsResponse.java @@ -120,7 +120,6 @@ public Builder from(ListAuditLogsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java index c2aeb87d..283378d2 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListEnvironmentsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java index baa96d3d..1fe2b636 100644 --- a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -128,6 +129,15 @@ public CompletableFuture> listCou if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -175,6 +185,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -221,6 +234,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -269,6 +291,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -308,6 +333,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -356,6 +390,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -395,6 +432,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -443,6 +489,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -489,6 +538,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -537,6 +595,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -611,6 +672,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -660,6 +730,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -730,6 +803,15 @@ public CompletableFuture> coun if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -777,6 +859,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -830,6 +915,15 @@ public CompletableFuture> listIn if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -877,6 +971,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -923,6 +1020,15 @@ public CompletableFuture> upser if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -970,6 +1076,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1009,6 +1118,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1057,6 +1175,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1114,6 +1235,15 @@ public CompletableFuture> listMete if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1161,6 +1291,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1207,6 +1340,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1255,6 +1397,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1306,6 +1451,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1354,6 +1508,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1400,6 +1557,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1448,6 +1614,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1487,6 +1656,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1536,6 +1714,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1652,6 +1833,15 @@ public CompletableFuture> l if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1700,6 +1890,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1746,6 +1939,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1794,6 +1996,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1833,6 +2038,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1881,6 +2095,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1999,6 +2216,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2048,6 +2274,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2087,6 +2316,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2135,6 +2373,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2181,6 +2422,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2229,6 +2479,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2335,6 +2588,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2383,6 +2645,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2489,6 +2754,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2537,6 +2811,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2583,6 +2860,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2632,6 +2918,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java index b3482eda..a54ca845 100644 --- a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -123,6 +124,15 @@ public BaseSchematicHttpResponse listCoupons( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -154,6 +164,8 @@ public BaseSchematicHttpResponse listCoupons( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -191,6 +203,15 @@ public BaseSchematicHttpResponse upsertBillingCoupo if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -223,6 +244,8 @@ public BaseSchematicHttpResponse upsertBillingCoupo Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -253,6 +276,15 @@ public BaseSchematicHttpResponse deleteBillingCoupo if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -285,6 +317,8 @@ public BaseSchematicHttpResponse deleteBillingCoupo Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -315,6 +349,15 @@ public BaseSchematicHttpResponse deleteBillingCus if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -347,6 +390,8 @@ public BaseSchematicHttpResponse deleteBillingCus Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -385,6 +430,15 @@ public BaseSchematicHttpResponse upsertBillingCus if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -417,6 +471,8 @@ public BaseSchematicHttpResponse upsertBillingCus Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -481,6 +537,15 @@ public BaseSchematicHttpResponse listCus if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -514,6 +579,8 @@ public BaseSchematicHttpResponse listCus Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -574,6 +641,15 @@ public BaseSchematicHttpResponse countCustomers( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -606,6 +682,8 @@ public BaseSchematicHttpResponse countCustomers( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -650,6 +728,15 @@ public BaseSchematicHttpResponse listInvoices( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -681,6 +768,8 @@ public BaseSchematicHttpResponse listInvoices( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -718,6 +807,15 @@ public BaseSchematicHttpResponse upsertInvoice( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -749,6 +847,8 @@ public BaseSchematicHttpResponse upsertInvoice( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -779,6 +879,15 @@ public BaseSchematicHttpResponse deleteBillingInvo if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -811,6 +920,8 @@ public BaseSchematicHttpResponse deleteBillingInvo Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -860,6 +971,15 @@ public BaseSchematicHttpResponse listMeters( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -891,6 +1011,8 @@ public BaseSchematicHttpResponse listMeters( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -928,6 +1050,15 @@ public BaseSchematicHttpResponse upsertBillingMeter( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -960,6 +1091,8 @@ public BaseSchematicHttpResponse upsertBillingMeter( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1002,6 +1135,15 @@ public BaseSchematicHttpResponse listPaymentMethods( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1034,6 +1176,8 @@ public BaseSchematicHttpResponse listPaymentMethods( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1072,6 +1216,15 @@ public BaseSchematicHttpResponse upsertPaymentMetho if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1104,6 +1257,8 @@ public BaseSchematicHttpResponse upsertPaymentMetho Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1135,6 +1290,15 @@ public BaseSchematicHttpResponse delete if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1168,6 +1332,8 @@ public BaseSchematicHttpResponse delete Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1274,6 +1440,15 @@ public BaseSchematicHttpResponse listBillingPrices( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1306,6 +1481,8 @@ public BaseSchematicHttpResponse listBillingPrices( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1344,6 +1521,15 @@ public BaseSchematicHttpResponse upsertBillingPrice( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1376,6 +1562,8 @@ public BaseSchematicHttpResponse upsertBillingPrice( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1406,6 +1594,15 @@ public BaseSchematicHttpResponse deleteBillingProd if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1438,6 +1635,8 @@ public BaseSchematicHttpResponse deleteBillingProd Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1548,6 +1747,15 @@ public BaseSchematicHttpResponse listBillingPr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1580,6 +1788,8 @@ public BaseSchematicHttpResponse listBillingPr Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1610,6 +1820,15 @@ public BaseSchematicHttpResponse deleteProductPrice( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1642,6 +1861,8 @@ public BaseSchematicHttpResponse deleteProductPrice( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1680,6 +1901,15 @@ public BaseSchematicHttpResponse upsertBillingProd if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1712,6 +1942,8 @@ public BaseSchematicHttpResponse upsertBillingProd Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1809,6 +2041,15 @@ public BaseSchematicHttpResponse listBillingProduct if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1841,6 +2082,8 @@ public BaseSchematicHttpResponse listBillingProduct Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1938,6 +2181,15 @@ public BaseSchematicHttpResponse countBillingProdu if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1970,6 +2222,8 @@ public BaseSchematicHttpResponse countBillingProdu Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2008,6 +2262,15 @@ public BaseSchematicHttpResponse upsertBillin if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2041,6 +2304,8 @@ public BaseSchematicHttpResponse upsertBillin Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CreateInvoiceRequestBody.java b/src/main/java/com/schematic/api/resources/billing/requests/CreateInvoiceRequestBody.java index 02d76e55..620be18f 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CreateInvoiceRequestBody.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CreateInvoiceRequestBody.java @@ -37,10 +37,14 @@ public final class CreateInvoiceRequestBody { private final Optional dueDate; + private final Optional endingBalance; + private final Optional externalId; private final Optional paymentMethodExternalId; + private final Optional startingBalance; + private final Optional status; private final Optional subscriptionExternalId; @@ -59,8 +63,10 @@ private CreateInvoiceRequestBody( String currency, String customerExternalId, Optional dueDate, + Optional endingBalance, Optional externalId, Optional paymentMethodExternalId, + Optional startingBalance, Optional status, Optional subscriptionExternalId, long subtotal, @@ -73,8 +79,10 @@ private CreateInvoiceRequestBody( this.currency = currency; this.customerExternalId = customerExternalId; this.dueDate = dueDate; + this.endingBalance = endingBalance; this.externalId = externalId; this.paymentMethodExternalId = paymentMethodExternalId; + this.startingBalance = startingBalance; this.status = status; this.subscriptionExternalId = subscriptionExternalId; this.subtotal = subtotal; @@ -117,6 +125,11 @@ public Optional getDueDate() { return dueDate; } + @JsonProperty("ending_balance") + public Optional getEndingBalance() { + return endingBalance; + } + @JsonProperty("external_id") public Optional getExternalId() { return externalId; @@ -127,6 +140,11 @@ public Optional getPaymentMethodExternalId() { return paymentMethodExternalId; } + @JsonProperty("starting_balance") + public Optional getStartingBalance() { + return startingBalance; + } + @JsonProperty("status") public Optional getStatus() { return status; @@ -166,8 +184,10 @@ private boolean equalTo(CreateInvoiceRequestBody other) { && currency.equals(other.currency) && customerExternalId.equals(other.customerExternalId) && dueDate.equals(other.dueDate) + && endingBalance.equals(other.endingBalance) && externalId.equals(other.externalId) && paymentMethodExternalId.equals(other.paymentMethodExternalId) + && startingBalance.equals(other.startingBalance) && status.equals(other.status) && subscriptionExternalId.equals(other.subscriptionExternalId) && subtotal == other.subtotal @@ -184,8 +204,10 @@ public int hashCode() { this.currency, this.customerExternalId, this.dueDate, + this.endingBalance, this.externalId, this.paymentMethodExternalId, + this.startingBalance, this.status, this.subscriptionExternalId, this.subtotal, @@ -242,6 +264,10 @@ public interface _FinalStage { _FinalStage dueDate(OffsetDateTime dueDate); + _FinalStage endingBalance(Optional endingBalance); + + _FinalStage endingBalance(Long endingBalance); + _FinalStage externalId(Optional externalId); _FinalStage externalId(String externalId); @@ -250,6 +276,10 @@ public interface _FinalStage { _FinalStage paymentMethodExternalId(String paymentMethodExternalId); + _FinalStage startingBalance(Optional startingBalance); + + _FinalStage startingBalance(Long startingBalance); + _FinalStage status(Optional status); _FinalStage status(InvoiceStatus status); @@ -293,10 +323,14 @@ public static final class Builder private Optional status = Optional.empty(); + private Optional startingBalance = Optional.empty(); + private Optional paymentMethodExternalId = Optional.empty(); private Optional externalId = Optional.empty(); + private Optional endingBalance = Optional.empty(); + private Optional dueDate = Optional.empty(); @JsonAnySetter @@ -313,8 +347,10 @@ public Builder from(CreateInvoiceRequestBody other) { currency(other.getCurrency()); customerExternalId(other.getCustomerExternalId()); dueDate(other.getDueDate()); + endingBalance(other.getEndingBalance()); externalId(other.getExternalId()); paymentMethodExternalId(other.getPaymentMethodExternalId()); + startingBalance(other.getStartingBalance()); status(other.getStatus()); subscriptionExternalId(other.getSubscriptionExternalId()); subtotal(other.getSubtotal()); @@ -410,6 +446,19 @@ public _FinalStage status(Optional status) { return this; } + @java.lang.Override + public _FinalStage startingBalance(Long startingBalance) { + this.startingBalance = Optional.ofNullable(startingBalance); + return this; + } + + @java.lang.Override + @JsonSetter(value = "starting_balance", nulls = Nulls.SKIP) + public _FinalStage startingBalance(Optional startingBalance) { + this.startingBalance = startingBalance; + return this; + } + @java.lang.Override public _FinalStage paymentMethodExternalId(String paymentMethodExternalId) { this.paymentMethodExternalId = Optional.ofNullable(paymentMethodExternalId); @@ -436,6 +485,19 @@ public _FinalStage externalId(Optional externalId) { return this; } + @java.lang.Override + public _FinalStage endingBalance(Long endingBalance) { + this.endingBalance = Optional.ofNullable(endingBalance); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ending_balance", nulls = Nulls.SKIP) + public _FinalStage endingBalance(Optional endingBalance) { + this.endingBalance = endingBalance; + return this; + } + @java.lang.Override public _FinalStage dueDate(OffsetDateTime dueDate) { this.dueDate = Optional.ofNullable(dueDate); @@ -459,8 +521,10 @@ public CreateInvoiceRequestBody build() { currency, customerExternalId, dueDate, + endingBalance, externalId, paymentMethodExternalId, + startingBalance, status, subscriptionExternalId, subtotal, diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java index 2828798b..cf40b811 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java b/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java index d0f55b80..13b3f7ea 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingPricesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingPricesResponse.java index 493f337c..5a59a51c 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingPricesResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingPricesResponse.java @@ -120,7 +120,6 @@ public Builder from(ListBillingPricesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductPricesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductPricesResponse.java index 893c33b3..fcc79d21 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductPricesResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductPricesResponse.java @@ -122,7 +122,6 @@ public Builder from(ListBillingProductPricesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java index 7f5311eb..04f91e65 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListBillingProductsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java index 7307a796..a653debc 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java @@ -120,7 +120,6 @@ public Builder from(ListCouponsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java index 0a2e945a..55862a00 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java @@ -123,7 +123,6 @@ public Builder from(ListCustomersWithSubscriptionsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java index 4183ddea..c61d48d3 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java @@ -120,7 +120,6 @@ public Builder from(ListInvoicesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java index 51409fe6..6639fca7 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java @@ -120,7 +120,6 @@ public Builder from(ListMetersResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java index 04c5afb8..9167a05a 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListPaymentMethodsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java index d2978c6f..32d9ba20 100644 --- a/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java +++ b/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.MediaTypes; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -82,6 +83,15 @@ public CompletableFuture> in if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -129,6 +139,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -175,6 +188,15 @@ public CompletableFuture> get if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -222,6 +244,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -268,6 +293,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -317,6 +351,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -362,6 +399,15 @@ public CompletableFuture> managePl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -409,6 +455,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -455,6 +504,15 @@ public CompletableFuture> p if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -503,6 +561,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -549,6 +610,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -597,6 +667,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -658,6 +731,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -707,6 +789,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java index a1505b0f..2ff09bf5 100644 --- a/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java +++ b/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.MediaTypes; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -77,6 +78,15 @@ public BaseSchematicHttpResponse internal( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -109,6 +119,8 @@ public BaseSchematicHttpResponse internal( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -146,6 +158,15 @@ public BaseSchematicHttpResponse getCheckoutData( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -178,6 +199,8 @@ public BaseSchematicHttpResponse getCheckoutData( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -216,6 +239,15 @@ public BaseSchematicHttpResponse previewCheckou if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -248,6 +280,8 @@ public BaseSchematicHttpResponse previewCheckou Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -285,6 +319,15 @@ public BaseSchematicHttpResponse managePlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -316,6 +359,8 @@ public BaseSchematicHttpResponse managePlan( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -353,6 +398,15 @@ public BaseSchematicHttpResponse previewManagePlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -385,6 +439,8 @@ public BaseSchematicHttpResponse previewManagePlan( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -422,6 +478,15 @@ public BaseSchematicHttpResponse cancelSubscription( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -454,6 +519,8 @@ public BaseSchematicHttpResponse cancelSubscription( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -506,6 +573,15 @@ public BaseSchematicHttpResponse upd if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -539,6 +615,8 @@ public BaseSchematicHttpResponse upd Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java index 72443aa7..1190e7ef 100644 --- a/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java +++ b/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -239,6 +240,15 @@ public CompletableFuture> listC if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -286,6 +296,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -332,6 +345,15 @@ public CompletableFuture> upser if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -379,6 +401,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -417,6 +442,15 @@ public CompletableFuture> getCompa if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -459,6 +493,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -518,6 +555,15 @@ public CompletableFuture> delet if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -565,6 +611,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -714,6 +763,15 @@ public CompletableFuture> coun if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -761,6 +819,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -807,6 +868,15 @@ public CompletableFuture> creat if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -854,6 +924,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -900,6 +973,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -948,6 +1030,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1005,6 +1090,15 @@ public CompletableFuture> looku if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1047,6 +1141,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1098,6 +1195,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1147,6 +1253,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1202,6 +1311,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1251,6 +1369,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1314,6 +1435,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1362,6 +1492,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1409,6 +1542,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1458,6 +1600,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1497,6 +1642,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1546,6 +1700,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1612,6 +1769,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1661,6 +1827,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1707,6 +1876,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1755,6 +1933,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1822,6 +2003,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1871,6 +2061,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1938,6 +2131,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1987,6 +2189,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2063,6 +2268,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2112,6 +2326,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2159,6 +2376,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2208,6 +2434,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2247,6 +2476,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2291,6 +2529,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2342,6 +2583,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2391,6 +2641,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2467,6 +2720,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2516,6 +2778,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2566,6 +2831,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2614,6 +2888,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2689,6 +2966,15 @@ public CompletableFuture> lis if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2736,6 +3022,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2774,6 +3063,15 @@ public CompletableFuture> getPl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2816,6 +3114,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2886,6 +3187,15 @@ public CompletableFuture> list if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2933,6 +3243,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2971,6 +3284,15 @@ public CompletableFuture> getPla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3013,6 +3335,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3059,6 +3384,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3107,6 +3441,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3177,6 +3514,15 @@ public CompletableFuture> cou if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3224,6 +3570,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3270,6 +3619,15 @@ public CompletableFuture> ups if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3317,6 +3675,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3384,6 +3745,15 @@ public CompletableFuture> listUsers if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3431,6 +3801,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3476,6 +3849,15 @@ public CompletableFuture> upsertUs if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3523,6 +3905,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3561,6 +3946,15 @@ public CompletableFuture> getUser( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3603,6 +3997,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3641,6 +4038,15 @@ public CompletableFuture> deleteUs if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3688,6 +4094,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3755,6 +4164,15 @@ public CompletableFuture> countUse if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3802,6 +4220,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3847,6 +4268,15 @@ public CompletableFuture> createUs if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3894,6 +4324,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3940,6 +4373,15 @@ public CompletableFuture> de if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3987,6 +4429,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -4025,6 +4470,15 @@ public CompletableFuture> lookupUs if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -4067,6 +4521,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java index f6c116b9..45b682d2 100644 --- a/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java +++ b/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -233,6 +234,15 @@ public BaseSchematicHttpResponse listCompanies( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -264,6 +274,8 @@ public BaseSchematicHttpResponse listCompanies( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -301,6 +313,15 @@ public BaseSchematicHttpResponse upsertCompany( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -332,6 +353,8 @@ public BaseSchematicHttpResponse upsertCompany( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -361,6 +384,15 @@ public BaseSchematicHttpResponse getCompany(String companyId if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -389,6 +421,8 @@ public BaseSchematicHttpResponse getCompany(String companyId Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -440,6 +474,15 @@ public BaseSchematicHttpResponse deleteCompany( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -471,6 +514,8 @@ public BaseSchematicHttpResponse deleteCompany( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -610,6 +655,15 @@ public BaseSchematicHttpResponse countCompanies( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -642,6 +696,8 @@ public BaseSchematicHttpResponse countCompanies( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -679,6 +735,15 @@ public BaseSchematicHttpResponse createCompany( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -710,6 +775,8 @@ public BaseSchematicHttpResponse createCompany( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -747,6 +814,15 @@ public BaseSchematicHttpResponse deleteCompanyByKey if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -779,6 +855,8 @@ public BaseSchematicHttpResponse deleteCompanyByKey Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -827,6 +905,15 @@ public BaseSchematicHttpResponse lookupCompany( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -855,6 +942,8 @@ public BaseSchematicHttpResponse lookupCompany( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -898,6 +987,15 @@ public BaseSchematicHttpResponse getCompanyBill if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -930,6 +1028,8 @@ public BaseSchematicHttpResponse getCompanyBill Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -975,6 +1075,15 @@ public BaseSchematicHttpResponse get if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1008,6 +1117,8 @@ public BaseSchematicHttpResponse get Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1063,6 +1174,15 @@ public BaseSchematicHttpResponse listCompanyMemb if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1095,6 +1215,8 @@ public BaseSchematicHttpResponse listCompanyMemb Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1133,6 +1255,15 @@ public BaseSchematicHttpResponse getOrCrea if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1166,6 +1297,8 @@ public BaseSchematicHttpResponse getOrCrea Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1197,6 +1330,15 @@ public BaseSchematicHttpResponse deleteCompanyM if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1229,6 +1371,8 @@ public BaseSchematicHttpResponse deleteCompanyM Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1286,6 +1430,15 @@ public BaseSchematicHttpResponse getActive if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1319,6 +1472,8 @@ public BaseSchematicHttpResponse getActive Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1356,6 +1511,15 @@ public BaseSchematicHttpResponse upsertCompanyTrait( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1388,6 +1552,8 @@ public BaseSchematicHttpResponse upsertCompanyTrait( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1447,6 +1613,15 @@ public BaseSchematicHttpResponse listEntityKey if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1479,6 +1654,8 @@ public BaseSchematicHttpResponse listEntityKey Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1538,6 +1715,15 @@ public BaseSchematicHttpResponse countEntityK if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1571,6 +1757,8 @@ public BaseSchematicHttpResponse countEntityK Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1638,6 +1826,15 @@ public BaseSchematicHttpResponse listEntityT if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1671,6 +1868,8 @@ public BaseSchematicHttpResponse listEntityT Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1709,6 +1908,15 @@ public BaseSchematicHttpResponse getOr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1742,6 +1950,8 @@ public BaseSchematicHttpResponse getOr Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1773,6 +1983,15 @@ public BaseSchematicHttpResponse getEntityTrai if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1802,6 +2021,8 @@ public BaseSchematicHttpResponse getEntityTrai Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1843,6 +2064,15 @@ public BaseSchematicHttpResponse updateEnti if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1876,6 +2106,8 @@ public BaseSchematicHttpResponse updateEnti Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1943,6 +2175,15 @@ public BaseSchematicHttpResponse countEntit if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1976,6 +2217,8 @@ public BaseSchematicHttpResponse countEntit Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2018,6 +2261,15 @@ public BaseSchematicHttpResponse getEntityTraitVal if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2050,6 +2302,8 @@ public BaseSchematicHttpResponse getEntityTraitVal Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2115,6 +2369,15 @@ public BaseSchematicHttpResponse listPlanChanges( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2147,6 +2410,8 @@ public BaseSchematicHttpResponse listPlanChanges( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2177,6 +2442,15 @@ public BaseSchematicHttpResponse getPlanChange( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2205,6 +2479,8 @@ public BaseSchematicHttpResponse getPlanChange( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2265,6 +2541,15 @@ public BaseSchematicHttpResponse listPlanTraits( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2297,6 +2582,8 @@ public BaseSchematicHttpResponse listPlanTraits( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2327,6 +2614,15 @@ public BaseSchematicHttpResponse getPlanTrait( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2355,6 +2651,8 @@ public BaseSchematicHttpResponse getPlanTrait( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2393,6 +2691,15 @@ public BaseSchematicHttpResponse updatePlanTraitsB if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2425,6 +2732,8 @@ public BaseSchematicHttpResponse updatePlanTraitsB Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2485,6 +2794,15 @@ public BaseSchematicHttpResponse countPlanTraits( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2517,6 +2835,8 @@ public BaseSchematicHttpResponse countPlanTraits( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2554,6 +2874,15 @@ public BaseSchematicHttpResponse upsertUserTrait( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2586,6 +2915,8 @@ public BaseSchematicHttpResponse upsertUserTrait( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2645,6 +2976,15 @@ public BaseSchematicHttpResponse listUsers( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2676,6 +3016,8 @@ public BaseSchematicHttpResponse listUsers( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2713,6 +3055,15 @@ public BaseSchematicHttpResponse upsertUser( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2744,6 +3095,8 @@ public BaseSchematicHttpResponse upsertUser( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2773,6 +3126,15 @@ public BaseSchematicHttpResponse getUser(String userId, Request if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2801,6 +3163,8 @@ public BaseSchematicHttpResponse getUser(String userId, Request Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2830,6 +3194,15 @@ public BaseSchematicHttpResponse deleteUser(String userId, R if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2861,6 +3234,8 @@ public BaseSchematicHttpResponse deleteUser(String userId, R Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2920,6 +3295,15 @@ public BaseSchematicHttpResponse countUsers( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2951,6 +3335,8 @@ public BaseSchematicHttpResponse countUsers( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2988,6 +3374,15 @@ public BaseSchematicHttpResponse createUser( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -3019,6 +3414,8 @@ public BaseSchematicHttpResponse createUser( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -3056,6 +3453,15 @@ public BaseSchematicHttpResponse deleteUserByKeys( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -3088,6 +3494,8 @@ public BaseSchematicHttpResponse deleteUserByKeys( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -3118,6 +3526,15 @@ public BaseSchematicHttpResponse lookupUser( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -3146,6 +3563,8 @@ public BaseSchematicHttpResponse lookupUser( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java index 80a38678..eebb43b4 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java index f4a825d7..802d1a02 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java index e7a3b4eb..2667babe 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java @@ -123,7 +123,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java index e64e87cd..ea41aeba 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java index e938d210..b96ab097 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java @@ -121,7 +121,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java index fa5866cd..4ecb7246 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull DeleteResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java index df41c204..724a7c41 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java @@ -123,7 +123,6 @@ public Builder from(GetActiveCompanySubscriptionResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetBillingEntityChildSubscriptionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetBillingEntityChildSubscriptionsResponse.java index 18b33ec6..3ef8fd78 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetBillingEntityChildSubscriptionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetBillingEntityChildSubscriptionsResponse.java @@ -123,7 +123,6 @@ public Builder from(GetBillingEntityChildSubscriptionsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetCompanyBillingEntityResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyBillingEntityResponse.java index 46e2f5bd..cd97d11f 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetCompanyBillingEntityResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyBillingEntityResponse.java @@ -122,7 +122,6 @@ public Builder from(GetCompanyBillingEntityResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java index 4d22c02c..48795ca5 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java @@ -120,7 +120,6 @@ public Builder from(GetEntityTraitValuesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java index ef54a8a0..09c4271e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCompaniesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java index 77f8e5c0..d9b96098 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCompanyMembershipsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java index 540a9cee..8d670d2c 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListEntityKeyDefinitionsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java index 945f0811..73ebe0e4 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java @@ -123,7 +123,6 @@ public Builder from(ListEntityTraitDefinitionsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java index b0bde3dd..265b1a80 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java @@ -120,7 +120,6 @@ public Builder from(ListPlanChangesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java index f9e116f9..6ae68b37 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java @@ -120,7 +120,6 @@ public Builder from(ListPlanTraitsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java index d8547101..19b03cc8 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java @@ -120,7 +120,6 @@ public Builder from(ListUsersResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java index a6376e15..8ec0628d 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CompanyDetailResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java b/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java index ed63fe75..9fe6e130 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull UserDetailResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java b/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java index c3713715..b1c992aa 100644 --- a/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java +++ b/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -95,6 +96,15 @@ public CompletableFuture> list if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -142,6 +152,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -188,6 +201,15 @@ public CompletableFuture> cre if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -235,6 +257,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -273,6 +298,15 @@ public CompletableFuture> getCom if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -315,6 +349,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -371,6 +408,15 @@ public CompletableFuture> upd if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -418,6 +464,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -456,6 +505,15 @@ public CompletableFuture> del if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -503,6 +561,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -561,6 +622,15 @@ public CompletableFuture> cou if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -608,6 +678,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -663,6 +736,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -706,6 +788,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java b/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java index 27cbb407..2ba1f055 100644 --- a/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java +++ b/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -89,6 +90,15 @@ public BaseSchematicHttpResponse listComponents( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -121,6 +131,8 @@ public BaseSchematicHttpResponse listComponents( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -158,6 +170,15 @@ public BaseSchematicHttpResponse createComponent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -190,6 +211,8 @@ public BaseSchematicHttpResponse createComponent( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -220,6 +243,15 @@ public BaseSchematicHttpResponse getComponent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -248,6 +280,8 @@ public BaseSchematicHttpResponse getComponent( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -296,6 +330,15 @@ public BaseSchematicHttpResponse updateComponent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -328,6 +371,8 @@ public BaseSchematicHttpResponse updateComponent( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -358,6 +403,15 @@ public BaseSchematicHttpResponse deleteComponent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -390,6 +444,8 @@ public BaseSchematicHttpResponse deleteComponent( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -438,6 +494,15 @@ public BaseSchematicHttpResponse countComponents( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -470,6 +535,8 @@ public BaseSchematicHttpResponse countComponents( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -516,6 +583,15 @@ public BaseSchematicHttpResponse previewComponentD if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -545,6 +621,8 @@ public BaseSchematicHttpResponse previewComponentD Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java b/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java index e90d21ed..48929ebb 100644 --- a/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java b/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java index 24978988..68e4b615 100644 --- a/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java @@ -120,7 +120,6 @@ public Builder from(ListComponentsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java b/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java index 187fdaee..6edd2ec6 100644 --- a/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java @@ -124,7 +124,6 @@ public ParamsStage data(@NotNull ComponentPreviewResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/componentspublic/AsyncRawComponentspublicClient.java b/src/main/java/com/schematic/api/resources/componentspublic/AsyncRawComponentspublicClient.java index 82d2b184..0101382c 100644 --- a/src/main/java/com/schematic/api/resources/componentspublic/AsyncRawComponentspublicClient.java +++ b/src/main/java/com/schematic/api/resources/componentspublic/AsyncRawComponentspublicClient.java @@ -10,6 +10,7 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; @@ -59,6 +60,15 @@ public CompletableFuture> getP if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -101,6 +111,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/componentspublic/RawComponentspublicClient.java b/src/main/java/com/schematic/api/resources/componentspublic/RawComponentspublicClient.java index d978ad25..a9571149 100644 --- a/src/main/java/com/schematic/api/resources/componentspublic/RawComponentspublicClient.java +++ b/src/main/java/com/schematic/api/resources/componentspublic/RawComponentspublicClient.java @@ -10,6 +10,7 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; @@ -54,6 +55,15 @@ public BaseSchematicHttpResponse getPublicPlans(RequestO if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -83,6 +93,8 @@ public BaseSchematicHttpResponse getPublicPlans(RequestO Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java index 912ca5a9..d792b262 100644 --- a/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java @@ -13,6 +13,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -143,6 +144,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -191,6 +201,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -237,6 +250,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -285,6 +307,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -324,6 +349,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -367,6 +401,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -414,6 +451,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -462,6 +508,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -501,6 +550,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -550,6 +608,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -589,6 +650,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -638,6 +708,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -708,6 +781,15 @@ public CompletableFuture> l if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -756,6 +838,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -802,6 +887,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -850,6 +944,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -888,6 +985,15 @@ public CompletableFuture> get if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -930,6 +1036,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -977,6 +1086,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1026,6 +1144,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1065,6 +1186,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1113,6 +1243,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1183,6 +1316,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1231,6 +1373,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1293,6 +1438,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1341,6 +1495,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1398,6 +1555,15 @@ public CompletableFuture> zeroOu if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1445,6 +1611,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1491,6 +1660,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1540,6 +1718,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1606,6 +1787,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1654,6 +1844,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1720,6 +1913,15 @@ public CompletableFuture> l if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1768,6 +1970,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1832,6 +2037,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1881,6 +2095,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1943,6 +2160,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1991,6 +2217,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2037,6 +2266,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2085,6 +2323,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2133,6 +2374,15 @@ public CompletableFuture> e if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2181,6 +2431,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2229,6 +2482,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2277,6 +2539,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2358,6 +2623,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2407,6 +2681,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2454,6 +2731,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2503,6 +2789,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2542,6 +2831,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2586,6 +2884,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2636,6 +2937,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2685,6 +2995,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2741,6 +3054,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2790,6 +3112,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2871,6 +3196,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2920,6 +3254,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2987,6 +3324,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3035,6 +3381,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -3102,6 +3451,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -3150,6 +3508,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java index 091862dc..d0d9daa7 100644 --- a/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java +++ b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java @@ -13,6 +13,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -137,6 +138,15 @@ public BaseSchematicHttpResponse listBillingCredits( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -169,6 +179,8 @@ public BaseSchematicHttpResponse listBillingCredits( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -207,6 +219,15 @@ public BaseSchematicHttpResponse createBillingCredi if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -239,6 +260,8 @@ public BaseSchematicHttpResponse createBillingCredi Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -269,6 +292,15 @@ public BaseSchematicHttpResponse getSingleBillin if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -298,6 +330,8 @@ public BaseSchematicHttpResponse getSingleBillin Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -337,6 +371,15 @@ public BaseSchematicHttpResponse updateBillingCredi if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -369,6 +412,8 @@ public BaseSchematicHttpResponse updateBillingCredi Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -399,6 +444,15 @@ public BaseSchematicHttpResponse softDeleteBill if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -431,6 +485,8 @@ public BaseSchematicHttpResponse softDeleteBill Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -462,6 +518,15 @@ public BaseSchematicHttpResponse listCompanyC if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -495,6 +560,8 @@ public BaseSchematicHttpResponse listCompanyC Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -555,6 +622,15 @@ public BaseSchematicHttpResponse listCreditBundles( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -587,6 +663,8 @@ public BaseSchematicHttpResponse listCreditBundles( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -625,6 +703,15 @@ public BaseSchematicHttpResponse createCreditBundle( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -657,6 +744,8 @@ public BaseSchematicHttpResponse createCreditBundle( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -687,6 +776,15 @@ public BaseSchematicHttpResponse getCreditBundle( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -716,6 +814,8 @@ public BaseSchematicHttpResponse getCreditBundle( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -755,6 +855,15 @@ public BaseSchematicHttpResponse updateCredit if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -788,6 +897,8 @@ public BaseSchematicHttpResponse updateCredit Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -818,6 +929,15 @@ public BaseSchematicHttpResponse deleteCreditBundle( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -850,6 +970,8 @@ public BaseSchematicHttpResponse deleteCreditBundle( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -910,6 +1032,15 @@ public BaseSchematicHttpResponse countCreditBundles( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -942,6 +1073,8 @@ public BaseSchematicHttpResponse countCreditBundles( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -995,6 +1128,15 @@ public BaseSchematicHttpResponse countBillingCredit if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1027,6 +1169,8 @@ public BaseSchematicHttpResponse countBillingCredit Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1075,6 +1219,15 @@ public BaseSchematicHttpResponse zeroOutGrant( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1106,6 +1259,8 @@ public BaseSchematicHttpResponse zeroOutGrant( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1144,6 +1299,15 @@ public BaseSchematicHttpResponse grantBill if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1177,6 +1341,8 @@ public BaseSchematicHttpResponse grantBill Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1233,6 +1399,15 @@ public BaseSchematicHttpResponse countCompanyGrants( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1265,6 +1440,8 @@ public BaseSchematicHttpResponse countCompanyGrants( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1321,6 +1498,15 @@ public BaseSchematicHttpResponse listCompanyGrants( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1353,6 +1539,8 @@ public BaseSchematicHttpResponse listCompanyGrants( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1409,6 +1597,15 @@ public BaseSchematicHttpResponse countBilling if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1442,6 +1639,8 @@ public BaseSchematicHttpResponse countBilling Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1495,6 +1694,15 @@ public BaseSchematicHttpResponse listGrantsForCredi if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1527,6 +1735,8 @@ public BaseSchematicHttpResponse listGrantsForCredi Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1565,6 +1775,15 @@ public BaseSchematicHttpResponse acquireCreditLease( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1597,6 +1816,8 @@ public BaseSchematicHttpResponse acquireCreditLease( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1637,6 +1858,15 @@ public BaseSchematicHttpResponse extendCreditLease( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1669,6 +1899,8 @@ public BaseSchematicHttpResponse extendCreditLease( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1709,6 +1941,15 @@ public BaseSchematicHttpResponse releaseCreditLease( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1741,6 +1982,8 @@ public BaseSchematicHttpResponse releaseCreditLease( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1813,6 +2056,15 @@ public BaseSchematicHttpResponse listBillin if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1846,6 +2098,8 @@ public BaseSchematicHttpResponse listBillin Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1884,6 +2138,15 @@ public BaseSchematicHttpResponse createBil if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1917,6 +2180,8 @@ public BaseSchematicHttpResponse createBil Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1948,6 +2213,15 @@ public BaseSchematicHttpResponse getSin if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1978,6 +2252,8 @@ public BaseSchematicHttpResponse getSin Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2017,6 +2293,15 @@ public BaseSchematicHttpResponse updateBil if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2050,6 +2335,8 @@ public BaseSchematicHttpResponse updateBil Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2097,6 +2384,15 @@ public BaseSchematicHttpResponse deleteBil if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2130,6 +2426,8 @@ public BaseSchematicHttpResponse deleteBil Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2202,6 +2500,15 @@ public BaseSchematicHttpResponse countBill if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2235,6 +2542,8 @@ public BaseSchematicHttpResponse countBill Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2294,6 +2603,15 @@ public BaseSchematicHttpResponse listCreditEventL if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2326,6 +2644,8 @@ public BaseSchematicHttpResponse listCreditEventL Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -2385,6 +2705,15 @@ public BaseSchematicHttpResponse countCreditEven if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -2417,6 +2746,8 @@ public BaseSchematicHttpResponse countCreditEven Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java index 7becf6b1..a3c6ee82 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java index 330da2e6..5204e2ba 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java index 5306b607..86c44149 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java @@ -123,7 +123,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCompanyGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountCompanyGrantsResponse.java index 000f5327..bbbdcc2d 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/CountCompanyGrantsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCompanyGrantsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java index 34ad3a76..48703491 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditEventLedgerResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditEventLedgerResponse.java index 190b6baf..5d8365ce 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/CountCreditEventLedgerResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditEventLedgerResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java b/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java index 28a76bdd..640ea586 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java @@ -123,7 +123,6 @@ public ParamsStage data(@NotNull DeleteResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java index 67e67a69..8ed48ec3 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListBillingCreditsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java index b9d19a79..8e844619 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java @@ -123,7 +123,6 @@ public Builder from(ListBillingPlanCreditGrantsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyCreditBalancesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyCreditBalancesResponse.java index 17aeeb63..60b1217b 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyCreditBalancesResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyCreditBalancesResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCompanyCreditBalancesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java index 0d2238cf..37a68b42 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCompanyGrantsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java index 2f4d47bd..25343d3a 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCreditBundlesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditEventLedgerResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditEventLedgerResponse.java index 4fd4df1d..50720e2a 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListCreditEventLedgerResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditEventLedgerResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCreditEventLedgerResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java index 9e2a14e1..9df25b10 100644 --- a/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java @@ -122,7 +122,6 @@ public Builder from(ListGrantsForCreditResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java b/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java index 64821ddb..25b21261 100644 --- a/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java +++ b/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; import com.schematic.api.core.ResponseBodyInputStream; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -74,6 +75,15 @@ public CompletableFuture> cr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -121,6 +131,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -160,6 +173,15 @@ public CompletableFuture> getDataExportAr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -202,6 +224,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java b/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java index a876e7da..0d70095b 100644 --- a/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java +++ b/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; import com.schematic.api.core.ResponseBodyInputStream; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -69,6 +70,15 @@ public BaseSchematicHttpResponse createDataExport( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -101,6 +111,8 @@ public BaseSchematicHttpResponse createDataExport( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -132,6 +144,15 @@ public BaseSchematicHttpResponse getDataExportArtifact( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try { Response response = client.newCall(okhttpRequest).execute(); ResponseBody responseBody = response.body(); @@ -160,6 +181,8 @@ public BaseSchematicHttpResponse getDataExportArtifact( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java b/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java index 39b36960..b76b7a49 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java +++ b/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -146,6 +147,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -194,6 +204,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -240,6 +253,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -288,6 +310,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -327,6 +352,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -370,6 +404,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -417,6 +454,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -465,6 +511,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -504,6 +553,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -552,6 +610,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -633,6 +694,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -681,6 +751,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -731,6 +804,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -779,6 +861,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -829,6 +914,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -877,6 +971,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -965,6 +1062,15 @@ public CompletableFuture> li if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1012,6 +1118,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1058,6 +1167,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1102,6 +1220,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1190,6 +1311,15 @@ public CompletableFuture> c if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1238,6 +1368,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1288,6 +1421,15 @@ public CompletableFuture> li if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1335,6 +1477,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1385,6 +1530,15 @@ public CompletableFuture> c if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1433,6 +1587,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1525,6 +1682,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1573,6 +1739,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1619,6 +1788,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1667,6 +1845,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1706,6 +1887,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1749,6 +1939,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1796,6 +1989,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1844,6 +2046,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1883,6 +2088,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1931,6 +2145,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1978,6 +2195,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2027,6 +2253,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2119,6 +2348,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -2167,6 +2405,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2213,6 +2454,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2262,6 +2512,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -2301,6 +2554,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -2345,6 +2607,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java b/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java index 9f00ad4d..85c3e5cf 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java +++ b/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -141,6 +142,15 @@ public BaseSchematicHttpResponse listCompanyOverri if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -173,6 +183,8 @@ public BaseSchematicHttpResponse listCompanyOverri Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -211,6 +223,15 @@ public BaseSchematicHttpResponse createCompanyOve if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -243,6 +264,8 @@ public BaseSchematicHttpResponse createCompanyOve Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -273,6 +296,15 @@ public BaseSchematicHttpResponse getCompanyOverride( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -302,6 +334,8 @@ public BaseSchematicHttpResponse getCompanyOverride( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -341,6 +375,15 @@ public BaseSchematicHttpResponse updateCompanyOve if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -373,6 +416,8 @@ public BaseSchematicHttpResponse updateCompanyOve Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -403,6 +448,15 @@ public BaseSchematicHttpResponse deleteCompanyOve if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -435,6 +489,8 @@ public BaseSchematicHttpResponse deleteCompanyOve Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -508,6 +564,15 @@ public BaseSchematicHttpResponse countCompanyOver if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -540,6 +605,8 @@ public BaseSchematicHttpResponse countCompanyOver Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -582,6 +649,15 @@ public BaseSchematicHttpResponse listFeatureCompan if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -614,6 +690,8 @@ public BaseSchematicHttpResponse listFeatureCompan Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -656,6 +734,15 @@ public BaseSchematicHttpResponse countFeatureComp if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -688,6 +775,8 @@ public BaseSchematicHttpResponse countFeatureComp Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -766,6 +855,15 @@ public BaseSchematicHttpResponse listFeatureUsage( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -798,6 +896,8 @@ public BaseSchematicHttpResponse listFeatureUsage( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -836,6 +936,15 @@ public BaseSchematicHttpResponse getFeatureUs if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -866,6 +975,8 @@ public BaseSchematicHttpResponse getFeatureUs Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -944,6 +1055,15 @@ public BaseSchematicHttpResponse countFeatureUsage( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -976,6 +1096,8 @@ public BaseSchematicHttpResponse countFeatureUsage( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1017,6 +1139,15 @@ public BaseSchematicHttpResponse listFeatureUsers( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1049,6 +1180,8 @@ public BaseSchematicHttpResponse listFeatureUsers( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1090,6 +1223,15 @@ public BaseSchematicHttpResponse countFeatureUsers( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1122,6 +1264,8 @@ public BaseSchematicHttpResponse countFeatureUsers( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1205,6 +1349,15 @@ public BaseSchematicHttpResponse listPlanEntitleme if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1237,6 +1390,8 @@ public BaseSchematicHttpResponse listPlanEntitleme Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1275,6 +1430,15 @@ public BaseSchematicHttpResponse createPlanEntitl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1307,6 +1471,8 @@ public BaseSchematicHttpResponse createPlanEntitl Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1337,6 +1503,15 @@ public BaseSchematicHttpResponse getPlanEntitlement( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1366,6 +1541,8 @@ public BaseSchematicHttpResponse getPlanEntitlement( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1405,6 +1582,15 @@ public BaseSchematicHttpResponse updatePlanEntitl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1437,6 +1623,8 @@ public BaseSchematicHttpResponse updatePlanEntitl Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1467,6 +1655,15 @@ public BaseSchematicHttpResponse deletePlanEntitl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1499,6 +1696,8 @@ public BaseSchematicHttpResponse deletePlanEntitl Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1538,6 +1737,15 @@ public BaseSchematicHttpResponse deletePlanEntitl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1571,6 +1779,8 @@ public BaseSchematicHttpResponse deletePlanEntitl Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1655,6 +1865,15 @@ public BaseSchematicHttpResponse countPlanEntitle if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1687,6 +1906,8 @@ public BaseSchematicHttpResponse countPlanEntitle Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1725,6 +1946,15 @@ public BaseSchematicHttpResponse duplicatePla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1758,6 +1988,8 @@ public BaseSchematicHttpResponse duplicatePla Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1789,6 +2021,15 @@ public BaseSchematicHttpResponse getFeatureUsa if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1818,6 +2059,8 @@ public BaseSchematicHttpResponse getFeatureUsa Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CreateBillingLinkedPlanEntitlementRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CreateBillingLinkedPlanEntitlementRequestBody.java index 96a25bfc..ce004bbe 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CreateBillingLinkedPlanEntitlementRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CreateBillingLinkedPlanEntitlementRequestBody.java @@ -20,6 +20,7 @@ import com.schematic.api.types.EntitlementValueType; import com.schematic.api.types.MetricPeriod; import com.schematic.api.types.MetricPeriodMonthReset; +import com.schematic.api.types.WarningTierRequestBody; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,6 +93,8 @@ public final class CreateBillingLinkedPlanEntitlementRequestBody { private final EntitlementValueType valueType; + private final Optional> warningTiers; + private final Optional yearlyMeteredPriceId; private final Optional> yearlyPriceTiers; @@ -134,6 +137,7 @@ private CreateBillingLinkedPlanEntitlementRequestBody( Optional valueNumeric, Optional valueTraitId, EntitlementValueType valueType, + Optional> warningTiers, Optional yearlyMeteredPriceId, Optional> yearlyPriceTiers, Optional yearlyUnitPrice, @@ -170,6 +174,7 @@ private CreateBillingLinkedPlanEntitlementRequestBody( this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; + this.warningTiers = warningTiers; this.yearlyMeteredPriceId = yearlyMeteredPriceId; this.yearlyPriceTiers = yearlyPriceTiers; this.yearlyUnitPrice = yearlyUnitPrice; @@ -338,6 +343,11 @@ public EntitlementValueType getValueType() { return valueType; } + @JsonProperty("warning_tiers") + public Optional> getWarningTiers() { + return warningTiers; + } + @JsonProperty("yearly_metered_price_id") public Optional getYearlyMeteredPriceId() { return yearlyMeteredPriceId; @@ -402,6 +412,7 @@ private boolean equalTo(CreateBillingLinkedPlanEntitlementRequestBody other) { && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType) + && warningTiers.equals(other.warningTiers) && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId) && yearlyPriceTiers.equals(other.yearlyPriceTiers) && yearlyUnitPrice.equals(other.yearlyUnitPrice) @@ -442,6 +453,7 @@ public int hashCode() { this.valueNumeric, this.valueTraitId, this.valueType, + this.warningTiers, this.yearlyMeteredPriceId, this.yearlyPriceTiers, this.yearlyUnitPrice, @@ -596,6 +608,10 @@ public interface _FinalStage { _FinalStage valueTraitId(String valueTraitId); + _FinalStage warningTiers(Optional> warningTiers); + + _FinalStage warningTiers(List warningTiers); + _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId); _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId); @@ -639,6 +655,8 @@ public static final class Builder private Optional yearlyMeteredPriceId = Optional.empty(); + private Optional> warningTiers = Optional.empty(); + private Optional valueTraitId = Optional.empty(); private Optional valueNumeric = Optional.empty(); @@ -729,6 +747,7 @@ public Builder from(CreateBillingLinkedPlanEntitlementRequestBody other) { valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); + warningTiers(other.getWarningTiers()); yearlyMeteredPriceId(other.getYearlyMeteredPriceId()); yearlyPriceTiers(other.getYearlyPriceTiers()); yearlyUnitPrice(other.getYearlyUnitPrice()); @@ -823,6 +842,19 @@ public _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId) { return this; } + @java.lang.Override + public _FinalStage warningTiers(List warningTiers) { + this.warningTiers = Optional.ofNullable(warningTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "warning_tiers", nulls = Nulls.SKIP) + public _FinalStage warningTiers(Optional> warningTiers) { + this.warningTiers = warningTiers; + return this; + } + @java.lang.Override public _FinalStage valueTraitId(String valueTraitId) { this.valueTraitId = Optional.ofNullable(valueTraitId); @@ -1209,6 +1241,7 @@ public CreateBillingLinkedPlanEntitlementRequestBody build() { valueNumeric, valueTraitId, valueType, + warningTiers, yearlyMeteredPriceId, yearlyPriceTiers, yearlyUnitPrice, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java index bae882b2..0d82a858 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java @@ -19,6 +19,7 @@ import com.schematic.api.types.EntitlementValueType; import com.schematic.api.types.MetricPeriod; import com.schematic.api.types.MetricPeriodMonthReset; +import com.schematic.api.types.WarningTierRequestBody; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -87,6 +88,8 @@ public final class CreatePlanEntitlementRequestBody { private final EntitlementValueType valueType; + private final Optional> warningTiers; + private final Optional yearlyMeteredPriceId; private final Optional> yearlyPriceTiers; @@ -127,6 +130,7 @@ private CreatePlanEntitlementRequestBody( Optional valueNumeric, Optional valueTraitId, EntitlementValueType valueType, + Optional> warningTiers, Optional yearlyMeteredPriceId, Optional> yearlyPriceTiers, Optional yearlyUnitPrice, @@ -161,6 +165,7 @@ private CreatePlanEntitlementRequestBody( this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; + this.warningTiers = warningTiers; this.yearlyMeteredPriceId = yearlyMeteredPriceId; this.yearlyPriceTiers = yearlyPriceTiers; this.yearlyUnitPrice = yearlyUnitPrice; @@ -319,6 +324,11 @@ public EntitlementValueType getValueType() { return valueType; } + @JsonProperty("warning_tiers") + public Optional> getWarningTiers() { + return warningTiers; + } + @JsonProperty("yearly_metered_price_id") public Optional getYearlyMeteredPriceId() { return yearlyMeteredPriceId; @@ -380,6 +390,7 @@ private boolean equalTo(CreatePlanEntitlementRequestBody other) { && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType) + && warningTiers.equals(other.warningTiers) && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId) && yearlyPriceTiers.equals(other.yearlyPriceTiers) && yearlyUnitPrice.equals(other.yearlyUnitPrice) @@ -418,6 +429,7 @@ public int hashCode() { this.valueNumeric, this.valueTraitId, this.valueType, + this.warningTiers, this.yearlyMeteredPriceId, this.yearlyPriceTiers, this.yearlyUnitPrice, @@ -564,6 +576,10 @@ public interface _FinalStage { _FinalStage valueTraitId(String valueTraitId); + _FinalStage warningTiers(Optional> warningTiers); + + _FinalStage warningTiers(List warningTiers); + _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId); _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId); @@ -597,6 +613,8 @@ public static final class Builder implements FeatureIdStage, PlanIdStage, ValueT private Optional yearlyMeteredPriceId = Optional.empty(); + private Optional> warningTiers = Optional.empty(); + private Optional valueTraitId = Optional.empty(); private Optional valueNumeric = Optional.empty(); @@ -685,6 +703,7 @@ public Builder from(CreatePlanEntitlementRequestBody other) { valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); + warningTiers(other.getWarningTiers()); yearlyMeteredPriceId(other.getYearlyMeteredPriceId()); yearlyPriceTiers(other.getYearlyPriceTiers()); yearlyUnitPrice(other.getYearlyUnitPrice()); @@ -765,6 +784,19 @@ public _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId) { return this; } + @java.lang.Override + public _FinalStage warningTiers(List warningTiers) { + this.warningTiers = Optional.ofNullable(warningTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "warning_tiers", nulls = Nulls.SKIP) + public _FinalStage warningTiers(Optional> warningTiers) { + this.warningTiers = warningTiers; + return this; + } + @java.lang.Override public _FinalStage valueTraitId(String valueTraitId) { this.valueTraitId = Optional.ofNullable(valueTraitId); @@ -1149,6 +1181,7 @@ public CreatePlanEntitlementRequestBody build() { valueNumeric, valueTraitId, valueType, + warningTiers, yearlyMeteredPriceId, yearlyPriceTiers, yearlyUnitPrice, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java index 2f80d734..265d0dc5 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java @@ -19,6 +19,7 @@ import com.schematic.api.types.EntitlementValueType; import com.schematic.api.types.MetricPeriod; import com.schematic.api.types.MetricPeriodMonthReset; +import com.schematic.api.types.WarningTierRequestBody; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -81,6 +82,8 @@ public final class UpdatePlanEntitlementRequestBody { private final EntitlementValueType valueType; + private final Optional> warningTiers; + private final Optional yearlyMeteredPriceId; private final Optional> yearlyPriceTiers; @@ -118,6 +121,7 @@ private UpdatePlanEntitlementRequestBody( Optional valueNumeric, Optional valueTraitId, EntitlementValueType valueType, + Optional> warningTiers, Optional yearlyMeteredPriceId, Optional> yearlyPriceTiers, Optional yearlyUnitPrice, @@ -149,6 +153,7 @@ private UpdatePlanEntitlementRequestBody( this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; + this.warningTiers = warningTiers; this.yearlyMeteredPriceId = yearlyMeteredPriceId; this.yearlyPriceTiers = yearlyPriceTiers; this.yearlyUnitPrice = yearlyUnitPrice; @@ -292,6 +297,11 @@ public EntitlementValueType getValueType() { return valueType; } + @JsonProperty("warning_tiers") + public Optional> getWarningTiers() { + return warningTiers; + } + @JsonProperty("yearly_metered_price_id") public Optional getYearlyMeteredPriceId() { return yearlyMeteredPriceId; @@ -350,6 +360,7 @@ private boolean equalTo(UpdatePlanEntitlementRequestBody other) { && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType) + && warningTiers.equals(other.warningTiers) && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId) && yearlyPriceTiers.equals(other.yearlyPriceTiers) && yearlyUnitPrice.equals(other.yearlyUnitPrice) @@ -385,6 +396,7 @@ public int hashCode() { this.valueNumeric, this.valueTraitId, this.valueType, + this.warningTiers, this.yearlyMeteredPriceId, this.yearlyPriceTiers, this.yearlyUnitPrice, @@ -519,6 +531,10 @@ public interface _FinalStage { _FinalStage valueTraitId(String valueTraitId); + _FinalStage warningTiers(Optional> warningTiers); + + _FinalStage warningTiers(List warningTiers); + _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId); _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId); @@ -548,6 +564,8 @@ public static final class Builder implements ValueTypeStage, _FinalStage { private Optional yearlyMeteredPriceId = Optional.empty(); + private Optional> warningTiers = Optional.empty(); + private Optional valueTraitId = Optional.empty(); private Optional valueNumeric = Optional.empty(); @@ -631,6 +649,7 @@ public Builder from(UpdatePlanEntitlementRequestBody other) { valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); + warningTiers(other.getWarningTiers()); yearlyMeteredPriceId(other.getYearlyMeteredPriceId()); yearlyPriceTiers(other.getYearlyPriceTiers()); yearlyUnitPrice(other.getYearlyUnitPrice()); @@ -697,6 +716,19 @@ public _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId) { return this; } + @java.lang.Override + public _FinalStage warningTiers(List warningTiers) { + this.warningTiers = Optional.ofNullable(warningTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "warning_tiers", nulls = Nulls.SKIP) + public _FinalStage warningTiers(Optional> warningTiers) { + this.warningTiers = warningTiers; + return this; + } + @java.lang.Override public _FinalStage valueTraitId(String valueTraitId) { this.valueTraitId = Optional.ofNullable(valueTraitId); @@ -1065,6 +1097,7 @@ public UpdatePlanEntitlementRequestBody build() { valueNumeric, valueTraitId, valueType, + warningTiers, yearlyMeteredPriceId, yearlyPriceTiers, yearlyUnitPrice, diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java index 3f2c1c39..26a037f6 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java index 7c788144..0a9c7215 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java index bd4268be..3a5c7e3d 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java index c4cf145b..34233454 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java index eb020784..0b46d68b 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java index 12ebcb07..a32866de 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java @@ -124,7 +124,6 @@ public ParamsStage data(@NotNull FeatureUsageDetailResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageTimeSeriesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageTimeSeriesResponse.java index e622d13b..8ece7ae2 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageTimeSeriesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageTimeSeriesResponse.java @@ -124,7 +124,6 @@ public ParamsStage data(@NotNull FeatureUsageTimeSeriesResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java index 8735bc53..b87fe377 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCompanyOverridesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java index 5b31d86a..d605f8c5 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java @@ -122,7 +122,6 @@ public Builder from(ListFeatureCompaniesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java index c327a477..c701cbd7 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java @@ -122,7 +122,6 @@ public Builder from(ListFeatureUsageResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java index a86d3c64..6f9a9602 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java @@ -122,7 +122,6 @@ public Builder from(ListFeatureUsersResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java index 31aef500..daaafffd 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListPlanEntitlementsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java b/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java index 9817099f..96e579ee 100644 --- a/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -81,6 +82,15 @@ public CompletableFuture> cr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -128,6 +138,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -190,6 +203,15 @@ public CompletableFuture> g if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -238,6 +260,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -315,6 +340,15 @@ public CompletableFuture> listEven if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -362,6 +396,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -408,6 +445,15 @@ public CompletableFuture> createE if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -455,6 +501,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -493,6 +542,15 @@ public CompletableFuture> getEvent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -535,6 +593,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -573,6 +634,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -617,6 +687,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/events/RawEventsClient.java b/src/main/java/com/schematic/api/resources/events/RawEventsClient.java index 8dcedbbf..0358da28 100644 --- a/src/main/java/com/schematic/api/resources/events/RawEventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/RawEventsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -76,6 +77,15 @@ public BaseSchematicHttpResponse createEventBatch( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -108,6 +118,8 @@ public BaseSchematicHttpResponse createEventBatch( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -160,6 +172,15 @@ public BaseSchematicHttpResponse getEventSummaries( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -192,6 +213,8 @@ public BaseSchematicHttpResponse getEventSummaries( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -261,6 +284,15 @@ public BaseSchematicHttpResponse listEvents( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -292,6 +324,8 @@ public BaseSchematicHttpResponse listEvents( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -329,6 +363,15 @@ public BaseSchematicHttpResponse createEvent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -360,6 +403,8 @@ public BaseSchematicHttpResponse createEvent( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -389,6 +434,15 @@ public BaseSchematicHttpResponse getEvent(String eventId, Requ if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -417,6 +471,8 @@ public BaseSchematicHttpResponse getEvent(String eventId, Requ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -446,6 +502,15 @@ public BaseSchematicHttpResponse getSegment if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -476,6 +541,8 @@ public BaseSchematicHttpResponse getSegment Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java b/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java index 621c0e6c..66e33805 100644 --- a/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java @@ -122,7 +122,6 @@ public Builder from(GetEventSummariesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java b/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java index be320fdb..e2d8fc26 100644 --- a/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java @@ -120,7 +120,6 @@ public Builder from(ListEventsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java b/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java index a776190e..99fc123c 100644 --- a/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java +++ b/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -147,6 +148,15 @@ public CompletableFuture> listFe if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -194,6 +204,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -240,6 +253,15 @@ public CompletableFuture> creat if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -287,6 +309,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -325,6 +350,15 @@ public CompletableFuture> getFeatu if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -367,6 +401,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -423,6 +460,15 @@ public CompletableFuture> updat if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -470,6 +516,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -508,6 +557,15 @@ public CompletableFuture> delet if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -555,6 +613,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -602,6 +663,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -651,6 +721,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -745,6 +818,15 @@ public CompletableFuture> count if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -792,6 +874,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -855,6 +940,15 @@ public CompletableFuture> listFlags if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -902,6 +996,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -947,6 +1044,15 @@ public CompletableFuture> createFl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -994,6 +1100,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1032,6 +1141,15 @@ public CompletableFuture> getFlag( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1074,6 +1192,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1121,6 +1242,15 @@ public CompletableFuture> updateFl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1168,6 +1298,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1206,6 +1339,15 @@ public CompletableFuture> deleteFl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1253,6 +1395,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1301,6 +1446,15 @@ public CompletableFuture> upd if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1348,6 +1502,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1405,6 +1562,15 @@ public CompletableFuture> checkFlag if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1452,6 +1618,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1505,6 +1674,15 @@ public CompletableFuture> checkFla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1552,6 +1730,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1598,6 +1779,15 @@ public CompletableFuture> chec if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1645,6 +1835,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1708,6 +1901,15 @@ public CompletableFuture> countFla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1755,6 +1957,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java b/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java index 0d6b9b92..c845d4f0 100644 --- a/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java +++ b/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -141,6 +142,15 @@ public BaseSchematicHttpResponse listFeatures( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -172,6 +182,8 @@ public BaseSchematicHttpResponse listFeatures( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -209,6 +221,15 @@ public BaseSchematicHttpResponse createFeature( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -240,6 +261,8 @@ public BaseSchematicHttpResponse createFeature( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -269,6 +292,15 @@ public BaseSchematicHttpResponse getFeature(String featureId if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -297,6 +329,8 @@ public BaseSchematicHttpResponse getFeature(String featureId Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -345,6 +379,15 @@ public BaseSchematicHttpResponse updateFeature( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -376,6 +419,8 @@ public BaseSchematicHttpResponse updateFeature( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -406,6 +451,15 @@ public BaseSchematicHttpResponse deleteFeature( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -437,6 +491,8 @@ public BaseSchematicHttpResponse deleteFeature( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -475,6 +531,15 @@ public BaseSchematicHttpResponse upsertF if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -508,6 +573,8 @@ public BaseSchematicHttpResponse upsertF Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -592,6 +659,15 @@ public BaseSchematicHttpResponse countFeatures( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -623,6 +699,8 @@ public BaseSchematicHttpResponse countFeatures( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -678,6 +756,15 @@ public BaseSchematicHttpResponse listFlags( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -709,6 +796,8 @@ public BaseSchematicHttpResponse listFlags( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -746,6 +835,15 @@ public BaseSchematicHttpResponse createFlag( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -777,6 +875,8 @@ public BaseSchematicHttpResponse createFlag( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -806,6 +906,15 @@ public BaseSchematicHttpResponse getFlag(String flagId, Request if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -834,6 +943,8 @@ public BaseSchematicHttpResponse getFlag(String flagId, Request Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -872,6 +983,15 @@ public BaseSchematicHttpResponse updateFlag( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -903,6 +1023,8 @@ public BaseSchematicHttpResponse updateFlag( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -932,6 +1054,15 @@ public BaseSchematicHttpResponse deleteFlag(String flagId, R if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -963,6 +1094,8 @@ public BaseSchematicHttpResponse deleteFlag(String flagId, R Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1003,6 +1136,15 @@ public BaseSchematicHttpResponse updateFlagRules( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1035,6 +1177,8 @@ public BaseSchematicHttpResponse updateFlagRules( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1082,6 +1226,15 @@ public BaseSchematicHttpResponse checkFlag( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1113,6 +1266,8 @@ public BaseSchematicHttpResponse checkFlag( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1158,6 +1313,15 @@ public BaseSchematicHttpResponse checkFlags( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1189,6 +1353,8 @@ public BaseSchematicHttpResponse checkFlags( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1226,6 +1392,15 @@ public BaseSchematicHttpResponse checkFlagsBulk( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1258,6 +1433,8 @@ public BaseSchematicHttpResponse checkFlagsBulk( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1313,6 +1490,15 @@ public BaseSchematicHttpResponse countFlags( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1344,6 +1530,8 @@ public BaseSchematicHttpResponse countFlags( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java b/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java index 76f6df8c..585d310b 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java b/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java index 395e1cca..60f5476d 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java @@ -121,7 +121,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java b/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java index 5504f661..74158f93 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java @@ -120,7 +120,6 @@ public Builder from(ListFeaturesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java b/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java index 647d4281..b6ab62e9 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java @@ -120,7 +120,6 @@ public Builder from(ListFlagsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/insights/AsyncRawInsightsClient.java b/src/main/java/com/schematic/api/resources/insights/AsyncRawInsightsClient.java index 5e2384e5..f6a27fa7 100644 --- a/src/main/java/com/schematic/api/resources/insights/AsyncRawInsightsClient.java +++ b/src/main/java/com/schematic/api/resources/insights/AsyncRawInsightsClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; @@ -83,6 +84,15 @@ public CompletableFuture> getActi if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -125,6 +135,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -171,6 +184,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -215,6 +237,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -266,6 +291,15 @@ public CompletableFuture> getPl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -308,6 +342,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -344,6 +381,15 @@ public CompletableFuture> getSumma if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -386,6 +432,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -430,6 +479,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -473,6 +531,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -519,6 +580,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -563,6 +633,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/insights/RawInsightsClient.java b/src/main/java/com/schematic/api/resources/insights/RawInsightsClient.java index dd38651d..f22adc4c 100644 --- a/src/main/java/com/schematic/api/resources/insights/RawInsightsClient.java +++ b/src/main/java/com/schematic/api/resources/insights/RawInsightsClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; import com.schematic.api.errors.NotFoundError; @@ -78,6 +79,15 @@ public BaseSchematicHttpResponse getActivity( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -106,6 +116,8 @@ public BaseSchematicHttpResponse getActivity( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -143,6 +155,15 @@ public BaseSchematicHttpResponse g if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -173,6 +194,8 @@ public BaseSchematicHttpResponse g Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -214,6 +237,15 @@ public BaseSchematicHttpResponse getPlanGrowth( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -242,6 +274,8 @@ public BaseSchematicHttpResponse getPlanGrowth( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -270,6 +304,15 @@ public BaseSchematicHttpResponse getSummary(RequestOptions r if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -298,6 +341,8 @@ public BaseSchematicHttpResponse getSummary(RequestOptions r Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -334,6 +379,15 @@ public BaseSchematicHttpResponse getTopFeaturesBy if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -363,6 +417,8 @@ public BaseSchematicHttpResponse getTopFeaturesBy Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -400,6 +456,15 @@ public BaseSchematicHttpResponse get if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -430,6 +495,8 @@ public BaseSchematicHttpResponse get Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/insights/types/GetActivityResponse.java b/src/main/java/com/schematic/api/resources/insights/types/GetActivityResponse.java index 3b94a8d8..96d7c66b 100644 --- a/src/main/java/com/schematic/api/resources/insights/types/GetActivityResponse.java +++ b/src/main/java/com/schematic/api/resources/insights/types/GetActivityResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull ActivityResponseResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentFeatureUsageTimeSeriesResponse.java b/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentFeatureUsageTimeSeriesResponse.java index 1d95f81a..33004f7c 100644 --- a/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentFeatureUsageTimeSeriesResponse.java +++ b/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentFeatureUsageTimeSeriesResponse.java @@ -125,7 +125,6 @@ public ParamsStage data(@NotNull EnvironmentFeatureUsageTimeSeriesResponseData d } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentTraitUsageTimeSeriesResponse.java b/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentTraitUsageTimeSeriesResponse.java index bb7b6e22..99b900c8 100644 --- a/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentTraitUsageTimeSeriesResponse.java +++ b/src/main/java/com/schematic/api/resources/insights/types/GetEnvironmentTraitUsageTimeSeriesResponse.java @@ -125,7 +125,6 @@ public ParamsStage data(@NotNull EnvironmentTraitUsageTimeSeriesResponseData dat } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/insights/types/GetPlanGrowthResponse.java b/src/main/java/com/schematic/api/resources/insights/types/GetPlanGrowthResponse.java index e47e4c94..2f7802fc 100644 --- a/src/main/java/com/schematic/api/resources/insights/types/GetPlanGrowthResponse.java +++ b/src/main/java/com/schematic/api/resources/insights/types/GetPlanGrowthResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull PlanGrowthResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/insights/types/GetTopFeaturesByUsageResponse.java b/src/main/java/com/schematic/api/resources/insights/types/GetTopFeaturesByUsageResponse.java index 847ea5b3..b3a671df 100644 --- a/src/main/java/com/schematic/api/resources/insights/types/GetTopFeaturesByUsageResponse.java +++ b/src/main/java/com/schematic/api/resources/insights/types/GetTopFeaturesByUsageResponse.java @@ -124,7 +124,6 @@ public ParamsStage data(@NotNull TopFeaturesByUsageResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java b/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java index 52cfc62a..c07d0d4a 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/AsyncRawIntegrationsapiClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -75,6 +76,15 @@ public CompletableFuture> runI if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -117,6 +127,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -191,6 +204,15 @@ public CompletableFuture> li if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -238,6 +260,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -278,6 +303,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -322,6 +356,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -368,6 +405,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -416,6 +462,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -462,6 +511,15 @@ public CompletableFuture> sta if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -509,6 +567,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -546,6 +607,15 @@ public CompletableFuture> l if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -589,6 +659,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -635,6 +708,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -683,6 +765,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -729,6 +814,15 @@ public CompletableFuture> insta if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -776,6 +870,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -815,6 +912,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -863,6 +969,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java b/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java index 639ff285..a9fb3278 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/RawIntegrationsapiClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -71,6 +72,15 @@ public BaseSchematicHttpResponse runIntegration( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -100,6 +110,8 @@ public BaseSchematicHttpResponse runIntegration( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -164,6 +176,15 @@ public BaseSchematicHttpResponse listIntegrations( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -196,6 +217,8 @@ public BaseSchematicHttpResponse listIntegrations( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -227,6 +250,15 @@ public BaseSchematicHttpResponse getIntegratio if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -256,6 +288,8 @@ public BaseSchematicHttpResponse getIntegratio Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -294,6 +328,15 @@ public BaseSchematicHttpResponse installIntegration( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -326,6 +369,8 @@ public BaseSchematicHttpResponse installIntegration( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -363,6 +408,15 @@ public BaseSchematicHttpResponse startDataImport( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -395,6 +449,8 @@ public BaseSchematicHttpResponse startDataImport( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -423,6 +479,15 @@ public BaseSchematicHttpResponse loadSampleDataSet(Re if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -452,6 +517,8 @@ public BaseSchematicHttpResponse loadSampleDataSet(Re Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -490,6 +557,15 @@ public BaseSchematicHttpResponse assumeStripeInst if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -522,6 +598,8 @@ public BaseSchematicHttpResponse assumeStripeInst Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -559,6 +637,15 @@ public BaseSchematicHttpResponse installStripe( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -590,6 +677,8 @@ public BaseSchematicHttpResponse installStripe( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -620,6 +709,15 @@ public BaseSchematicHttpResponse uninstallIntegrat if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -652,6 +750,8 @@ public BaseSchematicHttpResponse uninstallIntegrat Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/integrationsapi/types/ListIntegrationsResponse.java b/src/main/java/com/schematic/api/resources/integrationsapi/types/ListIntegrationsResponse.java index 1bab3ff2..eb11b0d5 100644 --- a/src/main/java/com/schematic/api/resources/integrationsapi/types/ListIntegrationsResponse.java +++ b/src/main/java/com/schematic/api/resources/integrationsapi/types/ListIntegrationsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListIntegrationsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/planbundle/AsyncRawPlanbundleClient.java b/src/main/java/com/schematic/api/resources/planbundle/AsyncRawPlanbundleClient.java index f911cd2b..f81b282c 100644 --- a/src/main/java/com/schematic/api/resources/planbundle/AsyncRawPlanbundleClient.java +++ b/src/main/java/com/schematic/api/resources/planbundle/AsyncRawPlanbundleClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.MediaTypes; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -76,6 +77,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -124,6 +134,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -170,6 +183,15 @@ public CompletableFuture> cr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -217,6 +239,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -264,6 +289,15 @@ public CompletableFuture> up if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -311,6 +345,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/planbundle/RawPlanbundleClient.java b/src/main/java/com/schematic/api/resources/planbundle/RawPlanbundleClient.java index 6b257343..9f392cbc 100644 --- a/src/main/java/com/schematic/api/resources/planbundle/RawPlanbundleClient.java +++ b/src/main/java/com/schematic/api/resources/planbundle/RawPlanbundleClient.java @@ -11,6 +11,7 @@ import com.schematic.api.core.MediaTypes; import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -72,6 +73,15 @@ public BaseSchematicHttpResponse createCustomPla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -104,6 +114,8 @@ public BaseSchematicHttpResponse createCustomPla Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -141,6 +153,15 @@ public BaseSchematicHttpResponse createPlanBundle( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -173,6 +194,8 @@ public BaseSchematicHttpResponse createPlanBundle( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -212,6 +235,15 @@ public BaseSchematicHttpResponse updatePlanBundle( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -244,6 +276,8 @@ public BaseSchematicHttpResponse updatePlanBundle( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/planbundle/requests/CreatePlanBundleRequestBody.java b/src/main/java/com/schematic/api/resources/planbundle/requests/CreatePlanBundleRequestBody.java index 1df9bc1d..f6465d44 100644 --- a/src/main/java/com/schematic/api/resources/planbundle/requests/CreatePlanBundleRequestBody.java +++ b/src/main/java/com/schematic/api/resources/planbundle/requests/CreatePlanBundleRequestBody.java @@ -15,7 +15,6 @@ import com.schematic.api.types.CreatePlanRequestBody; import com.schematic.api.types.PlanBundleCreditGrantRequestBody; import com.schematic.api.types.PlanBundleEntitlementRequestBody; -import com.schematic.api.types.UpdatePlanTraitTraitRequestBody; import com.schematic.api.types.UpsertBillingProductRequestBody; import java.util.ArrayList; import java.util.HashMap; @@ -35,8 +34,6 @@ public final class CreatePlanBundleRequestBody { private final Optional plan; - private final Optional> traits; - private final Map additionalProperties; private CreatePlanBundleRequestBody( @@ -44,13 +41,11 @@ private CreatePlanBundleRequestBody( Optional> creditGrants, List entitlements, Optional plan, - Optional> traits, Map additionalProperties) { this.billingProduct = billingProduct; this.creditGrants = creditGrants; this.entitlements = entitlements; this.plan = plan; - this.traits = traits; this.additionalProperties = additionalProperties; } @@ -74,11 +69,6 @@ public Optional getPlan() { return plan; } - @JsonProperty("traits") - public Optional> getTraits() { - return traits; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -94,13 +84,12 @@ private boolean equalTo(CreatePlanBundleRequestBody other) { return billingProduct.equals(other.billingProduct) && creditGrants.equals(other.creditGrants) && entitlements.equals(other.entitlements) - && plan.equals(other.plan) - && traits.equals(other.traits); + && plan.equals(other.plan); } @java.lang.Override public int hashCode() { - return Objects.hash(this.billingProduct, this.creditGrants, this.entitlements, this.plan, this.traits); + return Objects.hash(this.billingProduct, this.creditGrants, this.entitlements, this.plan); } @java.lang.Override @@ -122,8 +111,6 @@ public static final class Builder { private Optional plan = Optional.empty(); - private Optional> traits = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -134,7 +121,6 @@ public Builder from(CreatePlanBundleRequestBody other) { creditGrants(other.getCreditGrants()); entitlements(other.getEntitlements()); plan(other.getPlan()); - traits(other.getTraits()); return this; } @@ -192,20 +178,9 @@ public Builder plan(CreatePlanRequestBody plan) { return this; } - @JsonSetter(value = "traits", nulls = Nulls.SKIP) - public Builder traits(Optional> traits) { - this.traits = traits; - return this; - } - - public Builder traits(List traits) { - this.traits = Optional.ofNullable(traits); - return this; - } - public CreatePlanBundleRequestBody build() { return new CreatePlanBundleRequestBody( - billingProduct, creditGrants, entitlements, plan, traits, additionalProperties); + billingProduct, creditGrants, entitlements, plan, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/schematic/api/resources/planbundle/requests/UpdatePlanBundleRequestBody.java b/src/main/java/com/schematic/api/resources/planbundle/requests/UpdatePlanBundleRequestBody.java index 1d51756b..c7110401 100644 --- a/src/main/java/com/schematic/api/resources/planbundle/requests/UpdatePlanBundleRequestBody.java +++ b/src/main/java/com/schematic/api/resources/planbundle/requests/UpdatePlanBundleRequestBody.java @@ -15,7 +15,6 @@ import com.schematic.api.types.PlanBundleCreditGrantRequestBody; import com.schematic.api.types.PlanBundleEntitlementRequestBody; import com.schematic.api.types.UpdatePlanRequestBody; -import com.schematic.api.types.UpdatePlanTraitTraitRequestBody; import com.schematic.api.types.UpsertBillingProductRequestBody; import java.util.ArrayList; import java.util.HashMap; @@ -37,8 +36,6 @@ public final class UpdatePlanBundleRequestBody { private final Optional planVersionId; - private final Optional> traits; - private final Map additionalProperties; private UpdatePlanBundleRequestBody( @@ -47,14 +44,12 @@ private UpdatePlanBundleRequestBody( List entitlements, Optional plan, Optional planVersionId, - Optional> traits, Map additionalProperties) { this.billingProduct = billingProduct; this.creditGrants = creditGrants; this.entitlements = entitlements; this.plan = plan; this.planVersionId = planVersionId; - this.traits = traits; this.additionalProperties = additionalProperties; } @@ -83,11 +78,6 @@ public Optional getPlanVersionId() { return planVersionId; } - @JsonProperty("traits") - public Optional> getTraits() { - return traits; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -104,14 +94,12 @@ private boolean equalTo(UpdatePlanBundleRequestBody other) { && creditGrants.equals(other.creditGrants) && entitlements.equals(other.entitlements) && plan.equals(other.plan) - && planVersionId.equals(other.planVersionId) - && traits.equals(other.traits); + && planVersionId.equals(other.planVersionId); } @java.lang.Override public int hashCode() { - return Objects.hash( - this.billingProduct, this.creditGrants, this.entitlements, this.plan, this.planVersionId, this.traits); + return Objects.hash(this.billingProduct, this.creditGrants, this.entitlements, this.plan, this.planVersionId); } @java.lang.Override @@ -135,8 +123,6 @@ public static final class Builder { private Optional planVersionId = Optional.empty(); - private Optional> traits = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -148,7 +134,6 @@ public Builder from(UpdatePlanBundleRequestBody other) { entitlements(other.getEntitlements()); plan(other.getPlan()); planVersionId(other.getPlanVersionId()); - traits(other.getTraits()); return this; } @@ -217,20 +202,9 @@ public Builder planVersionId(String planVersionId) { return this; } - @JsonSetter(value = "traits", nulls = Nulls.SKIP) - public Builder traits(Optional> traits) { - this.traits = traits; - return this; - } - - public Builder traits(List traits) { - this.traits = Optional.ofNullable(traits); - return this; - } - public UpdatePlanBundleRequestBody build() { return new UpdatePlanBundleRequestBody( - billingProduct, creditGrants, entitlements, plan, planVersionId, traits, additionalProperties); + billingProduct, creditGrants, entitlements, plan, planVersionId, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java b/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java index d3e6ecfd..2781c838 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java +++ b/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -85,6 +86,15 @@ public CompletableFuture> getPla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -127,6 +137,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -173,6 +186,15 @@ public CompletableFuture> cre if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -220,6 +242,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -267,6 +292,15 @@ public CompletableFuture> upd if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -314,6 +348,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java b/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java index adb0c637..a8afedaa 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java +++ b/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -79,6 +80,15 @@ public BaseSchematicHttpResponse getPlanGroup( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -107,6 +117,8 @@ public BaseSchematicHttpResponse getPlanGroup( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -144,6 +156,15 @@ public BaseSchematicHttpResponse createPlanGroup( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -176,6 +197,8 @@ public BaseSchematicHttpResponse createPlanGroup( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -215,6 +238,15 @@ public BaseSchematicHttpResponse updatePlanGroup( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -247,6 +279,8 @@ public BaseSchematicHttpResponse updatePlanGroup( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java b/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java index 92e908f5..6a9e7b62 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java +++ b/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull PlanGroupDetailResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/planmigrations/AsyncRawPlanmigrationsClient.java b/src/main/java/com/schematic/api/resources/planmigrations/AsyncRawPlanmigrationsClient.java index 0d21687d..30763fdf 100644 --- a/src/main/java/com/schematic/api/resources/planmigrations/AsyncRawPlanmigrationsClient.java +++ b/src/main/java/com/schematic/api/resources/planmigrations/AsyncRawPlanmigrationsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -105,6 +106,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -153,6 +163,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -193,6 +206,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -241,6 +263,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -307,6 +332,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -355,6 +389,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -418,6 +455,15 @@ public CompletableFuture> list if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -465,6 +511,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -511,6 +560,15 @@ public CompletableFuture> cre if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -558,6 +616,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -597,6 +658,15 @@ public CompletableFuture> getMig if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -639,6 +709,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -687,6 +760,15 @@ public CompletableFuture> retr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -734,6 +816,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -797,6 +882,15 @@ public CompletableFuture> cou if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -844,6 +938,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/planmigrations/RawPlanmigrationsClient.java b/src/main/java/com/schematic/api/resources/planmigrations/RawPlanmigrationsClient.java index 28deea03..58c05476 100644 --- a/src/main/java/com/schematic/api/resources/planmigrations/RawPlanmigrationsClient.java +++ b/src/main/java/com/schematic/api/resources/planmigrations/RawPlanmigrationsClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -101,6 +102,15 @@ public BaseSchematicHttpResponse listCompanyMigra if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -133,6 +143,8 @@ public BaseSchematicHttpResponse listCompanyMigra Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -165,6 +177,15 @@ public BaseSchematicHttpResponse retryCompanyMigr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -197,6 +218,8 @@ public BaseSchematicHttpResponse retryCompanyMigr Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -255,6 +278,15 @@ public BaseSchematicHttpResponse countCompanyMig if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -287,6 +319,8 @@ public BaseSchematicHttpResponse countCompanyMig Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -340,6 +374,15 @@ public BaseSchematicHttpResponse listMigrations( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -372,6 +415,8 @@ public BaseSchematicHttpResponse listMigrations( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -409,6 +454,15 @@ public BaseSchematicHttpResponse createMigration( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -441,6 +495,8 @@ public BaseSchematicHttpResponse createMigration( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -471,6 +527,15 @@ public BaseSchematicHttpResponse getMigration( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -499,6 +564,8 @@ public BaseSchematicHttpResponse getMigration( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -539,6 +606,15 @@ public BaseSchematicHttpResponse retryMigration( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -571,6 +647,8 @@ public BaseSchematicHttpResponse retryMigration( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -624,6 +702,15 @@ public BaseSchematicHttpResponse countMigrations( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -656,6 +743,8 @@ public BaseSchematicHttpResponse countMigrations( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/planmigrations/types/CountCompanyMigrationsResponse.java b/src/main/java/com/schematic/api/resources/planmigrations/types/CountCompanyMigrationsResponse.java index a44b027b..b05bf4d6 100644 --- a/src/main/java/com/schematic/api/resources/planmigrations/types/CountCompanyMigrationsResponse.java +++ b/src/main/java/com/schematic/api/resources/planmigrations/types/CountCompanyMigrationsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/planmigrations/types/CountMigrationsResponse.java b/src/main/java/com/schematic/api/resources/planmigrations/types/CountMigrationsResponse.java index f565513d..0722d1a5 100644 --- a/src/main/java/com/schematic/api/resources/planmigrations/types/CountMigrationsResponse.java +++ b/src/main/java/com/schematic/api/resources/planmigrations/types/CountMigrationsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/planmigrations/types/ListCompanyMigrationsResponse.java b/src/main/java/com/schematic/api/resources/planmigrations/types/ListCompanyMigrationsResponse.java index 7567db52..8a5c6426 100644 --- a/src/main/java/com/schematic/api/resources/planmigrations/types/ListCompanyMigrationsResponse.java +++ b/src/main/java/com/schematic/api/resources/planmigrations/types/ListCompanyMigrationsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCompanyMigrationsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/planmigrations/types/ListMigrationsResponse.java b/src/main/java/com/schematic/api/resources/planmigrations/types/ListMigrationsResponse.java index 1e8f6369..e75293d2 100644 --- a/src/main/java/com/schematic/api/resources/planmigrations/types/ListMigrationsResponse.java +++ b/src/main/java/com/schematic/api/resources/planmigrations/types/ListMigrationsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListMigrationsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java b/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java index cef9a060..ff4c1082 100644 --- a/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java +++ b/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java @@ -13,6 +13,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -108,6 +109,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -156,6 +166,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -227,6 +240,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -275,6 +297,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -323,6 +348,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -372,6 +406,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -420,6 +457,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -468,6 +514,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -514,6 +563,15 @@ public CompletableFuture> cr if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -561,6 +619,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -693,6 +754,15 @@ public CompletableFuture> listPlans if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -740,6 +810,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -785,6 +858,15 @@ public CompletableFuture> createPl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -832,6 +914,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -884,6 +969,15 @@ public CompletableFuture> getPlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -926,6 +1020,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -973,6 +1070,15 @@ public CompletableFuture> updatePl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1020,6 +1126,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1058,6 +1167,15 @@ public CompletableFuture> deletePl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1105,6 +1223,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1153,6 +1274,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1202,6 +1332,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1248,6 +1381,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1297,6 +1439,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1348,6 +1493,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1397,6 +1551,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1448,6 +1605,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -1497,6 +1663,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1629,6 +1798,15 @@ public CompletableFuture> countPla if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1676,6 +1854,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1719,6 +1900,15 @@ public CompletableFuture> list if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1766,6 +1956,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1821,6 +2014,15 @@ public CompletableFuture> d if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1869,6 +2071,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -1917,6 +2122,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1965,6 +2179,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java b/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java index eec72953..fe8e855c 100644 --- a/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java +++ b/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java @@ -13,6 +13,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -104,6 +105,15 @@ public BaseSchematicHttpResponse updateCompanyPlans( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -136,6 +146,8 @@ public BaseSchematicHttpResponse updateCompanyPlans( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -199,6 +211,15 @@ public BaseSchematicHttpResponse listCustomPlanB if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -231,6 +252,8 @@ public BaseSchematicHttpResponse listCustomPlanB Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -271,6 +294,15 @@ public BaseSchematicHttpResponse markCustomPl if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -304,6 +336,8 @@ public BaseSchematicHttpResponse markCustomPl Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -344,6 +378,15 @@ public BaseSchematicHttpResponse retryCustomPlan if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -376,6 +419,8 @@ public BaseSchematicHttpResponse retryCustomPlan Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -413,6 +458,15 @@ public BaseSchematicHttpResponse createCustomPlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -445,6 +499,8 @@ public BaseSchematicHttpResponse createCustomPlan( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -569,6 +625,15 @@ public BaseSchematicHttpResponse listPlans( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -600,6 +665,8 @@ public BaseSchematicHttpResponse listPlans( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -637,6 +704,15 @@ public BaseSchematicHttpResponse createPlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -668,6 +744,8 @@ public BaseSchematicHttpResponse createPlan( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -710,6 +788,15 @@ public BaseSchematicHttpResponse getPlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -738,6 +825,8 @@ public BaseSchematicHttpResponse getPlan( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -776,6 +865,15 @@ public BaseSchematicHttpResponse updatePlan( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -807,6 +905,8 @@ public BaseSchematicHttpResponse updatePlan( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -836,6 +936,15 @@ public BaseSchematicHttpResponse deletePlan(String planId, R if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -867,6 +976,8 @@ public BaseSchematicHttpResponse deletePlan(String planId, R Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -907,6 +1018,15 @@ public BaseSchematicHttpResponse upsertBilling if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -939,6 +1059,8 @@ public BaseSchematicHttpResponse upsertBilling Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -977,6 +1099,15 @@ public BaseSchematicHttpResponse upsertPlan if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1010,6 +1141,8 @@ public BaseSchematicHttpResponse upsertPlan Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1052,6 +1185,15 @@ public BaseSchematicHttpResponse listB if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1085,6 +1227,8 @@ public BaseSchematicHttpResponse listB Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1127,6 +1271,15 @@ public BaseSchematicHttpResponse coun if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1160,6 +1313,8 @@ public BaseSchematicHttpResponse coun Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1284,6 +1439,15 @@ public BaseSchematicHttpResponse countPlans( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1315,6 +1479,8 @@ public BaseSchematicHttpResponse countPlans( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1349,6 +1515,15 @@ public BaseSchematicHttpResponse listPlanIssues( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1381,6 +1556,8 @@ public BaseSchematicHttpResponse listPlanIssues( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1428,6 +1605,15 @@ public BaseSchematicHttpResponse deletePlanVersion( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1460,6 +1646,8 @@ public BaseSchematicHttpResponse deletePlanVersion( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -1500,6 +1688,15 @@ public BaseSchematicHttpResponse publishPlanVersion( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -1532,6 +1729,8 @@ public BaseSchematicHttpResponse publishPlanVersion( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/plans/requests/CountBillingProductMatchCompaniesRequest.java b/src/main/java/com/schematic/api/resources/plans/requests/CountBillingProductMatchCompaniesRequest.java index c6f6d5fe..f9338afe 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/CountBillingProductMatchCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/CountBillingProductMatchCompaniesRequest.java @@ -172,7 +172,6 @@ public Builder from(CountBillingProductMatchCompaniesRequest other) { } /** - *

The plan ID to find billing product match companies for

*

The plan ID to find billing product match companies for

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/requests/ListBillingProductMatchCompaniesRequest.java b/src/main/java/com/schematic/api/resources/plans/requests/ListBillingProductMatchCompaniesRequest.java index 198bdf15..85aae39a 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/ListBillingProductMatchCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/ListBillingProductMatchCompaniesRequest.java @@ -172,7 +172,6 @@ public Builder from(ListBillingProductMatchCompaniesRequest other) { } /** - *

The plan ID to find billing product match companies for

*

The plan ID to find billing product match companies for

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/CountBillingProductMatchCompaniesResponse.java b/src/main/java/com/schematic/api/resources/plans/types/CountBillingProductMatchCompaniesResponse.java index a00bdd3d..9253c559 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CountBillingProductMatchCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CountBillingProductMatchCompaniesResponse.java @@ -125,7 +125,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java b/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java index f7e7e506..bb217645 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java @@ -121,7 +121,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/DeletePlanVersionResponse.java b/src/main/java/com/schematic/api/resources/plans/types/DeletePlanVersionResponse.java index f7a81c64..680b1663 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/DeletePlanVersionResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/DeletePlanVersionResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull DeleteResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java b/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java index ea211cfc..2af3ef50 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull PlanDetailResponseData data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListBillingProductMatchCompaniesResponse.java b/src/main/java/com/schematic/api/resources/plans/types/ListBillingProductMatchCompaniesResponse.java index b50a017a..6ff77d62 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListBillingProductMatchCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListBillingProductMatchCompaniesResponse.java @@ -123,7 +123,6 @@ public Builder from(ListBillingProductMatchCompaniesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListCustomPlanBillingsResponse.java b/src/main/java/com/schematic/api/resources/plans/types/ListCustomPlanBillingsResponse.java index 820ea1e7..e3ef891c 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListCustomPlanBillingsResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListCustomPlanBillingsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListCustomPlanBillingsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java index e9953000..bc429dec 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java @@ -120,7 +120,6 @@ public Builder from(ListPlanIssuesResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java index dd384846..6a31011f 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java @@ -120,7 +120,6 @@ public Builder from(ListPlansResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/scheduledcheckout/AsyncRawScheduledcheckoutClient.java b/src/main/java/com/schematic/api/resources/scheduledcheckout/AsyncRawScheduledcheckoutClient.java index b33d6e42..dbabeaa8 100644 --- a/src/main/java/com/schematic/api/resources/scheduledcheckout/AsyncRawScheduledcheckoutClient.java +++ b/src/main/java/com/schematic/api/resources/scheduledcheckout/AsyncRawScheduledcheckoutClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -95,6 +96,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -143,6 +153,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -189,6 +202,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -238,6 +260,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -277,6 +302,15 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -320,6 +354,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -379,6 +416,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @@ -428,6 +474,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/scheduledcheckout/RawScheduledcheckoutClient.java b/src/main/java/com/schematic/api/resources/scheduledcheckout/RawScheduledcheckoutClient.java index 287dd6a7..f21cdfce 100644 --- a/src/main/java/com/schematic/api/resources/scheduledcheckout/RawScheduledcheckoutClient.java +++ b/src/main/java/com/schematic/api/resources/scheduledcheckout/RawScheduledcheckoutClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -91,6 +92,15 @@ public BaseSchematicHttpResponse listScheduledCh if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -123,6 +133,8 @@ public BaseSchematicHttpResponse listScheduledCh Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -161,6 +173,15 @@ public BaseSchematicHttpResponse createSchedule if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -193,6 +214,8 @@ public BaseSchematicHttpResponse createSchedule Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -223,6 +246,15 @@ public BaseSchematicHttpResponse getScheduledCheck if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -252,6 +284,8 @@ public BaseSchematicHttpResponse getScheduledCheck Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -303,6 +337,15 @@ public BaseSchematicHttpResponse updateSchedule if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -335,6 +378,8 @@ public BaseSchematicHttpResponse updateSchedule Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/scheduledcheckout/types/ListScheduledCheckoutsResponse.java b/src/main/java/com/schematic/api/resources/scheduledcheckout/types/ListScheduledCheckoutsResponse.java index a0e20491..62351389 100644 --- a/src/main/java/com/schematic/api/resources/scheduledcheckout/types/ListScheduledCheckoutsResponse.java +++ b/src/main/java/com/schematic/api/resources/scheduledcheckout/types/ListScheduledCheckoutsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListScheduledCheckoutsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java index cd7e62d3..8f4fbb7e 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -107,6 +108,15 @@ public CompletableFuture> l if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -155,6 +165,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -194,6 +207,15 @@ public CompletableFuture> get if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -236,6 +258,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -301,6 +326,15 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -349,6 +383,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -407,6 +444,15 @@ public CompletableFuture> listWe if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -454,6 +500,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -500,6 +549,15 @@ public CompletableFuture> creat if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -547,6 +605,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -585,6 +646,15 @@ public CompletableFuture> getWebho if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -627,6 +697,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -683,6 +756,15 @@ public CompletableFuture> updat if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -730,6 +812,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -768,6 +853,15 @@ public CompletableFuture> delet if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -815,6 +909,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -863,6 +960,15 @@ public CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -911,6 +1017,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } @@ -969,6 +1078,15 @@ public CompletableFuture> count if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override @@ -1016,6 +1134,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO future.completeExceptionally(new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); } diff --git a/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java index 9c6ca22f..5d7318ee 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java @@ -12,6 +12,7 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.QueryStringMapper; import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.RetryInterceptor; import com.schematic.api.errors.BadRequestError; import com.schematic.api.errors.ForbiddenError; import com.schematic.api.errors.InternalServerError; @@ -101,6 +102,15 @@ public BaseSchematicHttpResponse listWebhookEvents( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -133,6 +143,8 @@ public BaseSchematicHttpResponse listWebhookEvents( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -163,6 +175,15 @@ public BaseSchematicHttpResponse getWebhookEvent( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -192,6 +213,8 @@ public BaseSchematicHttpResponse getWebhookEvent( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -247,6 +270,15 @@ public BaseSchematicHttpResponse countWebhookEvents( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -279,6 +311,8 @@ public BaseSchematicHttpResponse countWebhookEvents( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -327,6 +361,15 @@ public BaseSchematicHttpResponse listWebhooks( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -358,6 +401,8 @@ public BaseSchematicHttpResponse listWebhooks( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -395,6 +440,15 @@ public BaseSchematicHttpResponse createWebhook( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -426,6 +480,8 @@ public BaseSchematicHttpResponse createWebhook( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -455,6 +511,15 @@ public BaseSchematicHttpResponse getWebhook(String webhookId if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -483,6 +548,8 @@ public BaseSchematicHttpResponse getWebhook(String webhookId Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -531,6 +598,15 @@ public BaseSchematicHttpResponse updateWebhook( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -562,6 +638,8 @@ public BaseSchematicHttpResponse updateWebhook( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -592,6 +670,15 @@ public BaseSchematicHttpResponse deleteWebhook( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -623,6 +710,8 @@ public BaseSchematicHttpResponse deleteWebhook( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -663,6 +752,15 @@ public BaseSchematicHttpResponse sendTestWebhookA if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -695,6 +793,8 @@ public BaseSchematicHttpResponse sendTestWebhookA Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } @@ -743,6 +843,15 @@ public BaseSchematicHttpResponse countWebhooks( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; @@ -774,6 +883,8 @@ public BaseSchematicHttpResponse countWebhooks( Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new BaseSchematicApiException( "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to deserialize response: " + e.getMessage(), e); } catch (IOException e) { throw new BaseSchematicException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java index 4b9e1d8f..caf8fd99 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java index ad59a7bf..4c62e851 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java @@ -122,7 +122,6 @@ public ParamsStage data(@NotNull CountResponse data) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java index c6b37a72..7633ff34 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java @@ -122,7 +122,6 @@ public Builder from(ListWebhookEventsResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java index 8be9790c..915bdaf7 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java @@ -120,7 +120,6 @@ public Builder from(ListWebhooksResponse other) { } /** - *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/AccountMemberPermission.java b/src/main/java/com/schematic/api/types/AccountMemberPermission.java index 9767bbe7..16b07f5f 100644 --- a/src/main/java/com/schematic/api/types/AccountMemberPermission.java +++ b/src/main/java/com/schematic/api/types/AccountMemberPermission.java @@ -19,6 +19,9 @@ public final class AccountMemberPermission { public static final AccountMemberPermission FEATURES_EDIT = new AccountMemberPermission(Value.FEATURES_EDIT, "features_edit"); + public static final AccountMemberPermission CUSTOM_PLANS_EDIT = + new AccountMemberPermission(Value.CUSTOM_PLANS_EDIT, "custom_plans_edit"); + public static final AccountMemberPermission PLAN_ENTITLEMENTS_EDIT = new AccountMemberPermission(Value.PLAN_ENTITLEMENTS_EDIT, "plan_entitlements_edit"); @@ -90,6 +93,8 @@ public T visit(Visitor visitor) { return visitor.visitPlanBillingEdit(); case FEATURES_EDIT: return visitor.visitFeaturesEdit(); + case CUSTOM_PLANS_EDIT: + return visitor.visitCustomPlansEdit(); case PLAN_ENTITLEMENTS_EDIT: return visitor.visitPlanEntitlementsEdit(); case FLAG_RULES_EDIT: @@ -127,6 +132,8 @@ public static AccountMemberPermission valueOf(String value) { return PLAN_BILLING_EDIT; case "features_edit": return FEATURES_EDIT; + case "custom_plans_edit": + return CUSTOM_PLANS_EDIT; case "plan_entitlements_edit": return PLAN_ENTITLEMENTS_EDIT; case "flag_rules_edit": @@ -159,6 +166,8 @@ public enum Value { COMPONENTS_EDIT, + CUSTOM_PLANS_EDIT, + DATA_EXPORTS_EDIT, FEATURES_EDIT, @@ -191,6 +200,8 @@ public interface Visitor { T visitComponentsEdit(); + T visitCustomPlansEdit(); + T visitDataExportsEdit(); T visitFeaturesEdit(); diff --git a/src/main/java/com/schematic/api/types/ApiError.java b/src/main/java/com/schematic/api/types/ApiError.java index 9e3d917b..1beb353c 100644 --- a/src/main/java/com/schematic/api/types/ApiError.java +++ b/src/main/java/com/schematic/api/types/ApiError.java @@ -98,7 +98,6 @@ public Builder from(ApiError other) { } /** - *

Error message

*

Error message

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/BillingCreditGrantZeroedOutReason.java b/src/main/java/com/schematic/api/types/BillingCreditGrantZeroedOutReason.java index dc9aa965..04117ab2 100644 --- a/src/main/java/com/schematic/api/types/BillingCreditGrantZeroedOutReason.java +++ b/src/main/java/com/schematic/api/types/BillingCreditGrantZeroedOutReason.java @@ -7,6 +7,9 @@ import com.fasterxml.jackson.annotation.JsonValue; public final class BillingCreditGrantZeroedOutReason { + public static final BillingCreditGrantZeroedOutReason INTEGRATION_UNINSTALLED = + new BillingCreditGrantZeroedOutReason(Value.INTEGRATION_UNINSTALLED, "integration_uninstalled"); + public static final BillingCreditGrantZeroedOutReason PLAN_CHANGE = new BillingCreditGrantZeroedOutReason(Value.PLAN_CHANGE, "plan_change"); @@ -16,6 +19,9 @@ public final class BillingCreditGrantZeroedOutReason { public static final BillingCreditGrantZeroedOutReason PLAN_PERIOD_RESET = new BillingCreditGrantZeroedOutReason(Value.PLAN_PERIOD_RESET, "plan_period_reset"); + public static final BillingCreditGrantZeroedOutReason CUSTOMER_ARCHIVED = + new BillingCreditGrantZeroedOutReason(Value.CUSTOMER_ARCHIVED, "customer_archived"); + public static final BillingCreditGrantZeroedOutReason RECONCILED = new BillingCreditGrantZeroedOutReason(Value.RECONCILED, "reconciled"); @@ -55,12 +61,16 @@ public int hashCode() { public T visit(Visitor visitor) { switch (value) { + case INTEGRATION_UNINSTALLED: + return visitor.visitIntegrationUninstalled(); case PLAN_CHANGE: return visitor.visitPlanChange(); case EXPIRED: return visitor.visitExpired(); case PLAN_PERIOD_RESET: return visitor.visitPlanPeriodReset(); + case CUSTOMER_ARCHIVED: + return visitor.visitCustomerArchived(); case RECONCILED: return visitor.visitReconciled(); case MANUAL: @@ -74,12 +84,16 @@ public T visit(Visitor visitor) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static BillingCreditGrantZeroedOutReason valueOf(String value) { switch (value) { + case "integration_uninstalled": + return INTEGRATION_UNINSTALLED; case "plan_change": return PLAN_CHANGE; case "expired": return EXPIRED; case "plan_period_reset": return PLAN_PERIOD_RESET; + case "customer_archived": + return CUSTOMER_ARCHIVED; case "reconciled": return RECONCILED; case "manual": @@ -90,8 +104,12 @@ public static BillingCreditGrantZeroedOutReason valueOf(String value) { } public enum Value { + CUSTOMER_ARCHIVED, + EXPIRED, + INTEGRATION_UNINSTALLED, + MANUAL, PLAN_CHANGE, @@ -104,8 +122,12 @@ public enum Value { } public interface Visitor { + T visitCustomerArchived(); + T visitExpired(); + T visitIntegrationUninstalled(); + T visitManual(); T visitPlanChange(); diff --git a/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResetCadence.java b/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResetCadence.java index 408e5378..825d878b 100644 --- a/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResetCadence.java +++ b/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResetCadence.java @@ -10,9 +10,15 @@ public final class BillingPlanCreditGrantResetCadence { public static final BillingPlanCreditGrantResetCadence YEARLY = new BillingPlanCreditGrantResetCadence(Value.YEARLY, "yearly"); + public static final BillingPlanCreditGrantResetCadence QUARTERLY = + new BillingPlanCreditGrantResetCadence(Value.QUARTERLY, "quarterly"); + public static final BillingPlanCreditGrantResetCadence DAILY = new BillingPlanCreditGrantResetCadence(Value.DAILY, "daily"); + public static final BillingPlanCreditGrantResetCadence EVERY_6_MONTHS = + new BillingPlanCreditGrantResetCadence(Value.EVERY_6_MONTHS, "every_6_months"); + public static final BillingPlanCreditGrantResetCadence WEEKLY = new BillingPlanCreditGrantResetCadence(Value.WEEKLY, "weekly"); @@ -54,8 +60,12 @@ public T visit(Visitor visitor) { switch (value) { case YEARLY: return visitor.visitYearly(); + case QUARTERLY: + return visitor.visitQuarterly(); case DAILY: return visitor.visitDaily(); + case EVERY_6_MONTHS: + return visitor.visitEvery6Months(); case WEEKLY: return visitor.visitWeekly(); case MONTHLY: @@ -71,8 +81,12 @@ public static BillingPlanCreditGrantResetCadence valueOf(String value) { switch (value) { case "yearly": return YEARLY; + case "quarterly": + return QUARTERLY; case "daily": return DAILY; + case "every_6_months": + return EVERY_6_MONTHS; case "weekly": return WEEKLY; case "monthly": @@ -85,8 +99,12 @@ public static BillingPlanCreditGrantResetCadence valueOf(String value) { public enum Value { DAILY, + EVERY_6_MONTHS, + MONTHLY, + QUARTERLY, + WEEKLY, YEARLY, @@ -97,8 +115,12 @@ public enum Value { public interface Visitor { T visitDaily(); + T visitEvery6Months(); + T visitMonthly(); + T visitQuarterly(); + T visitWeekly(); T visitYearly(); diff --git a/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java b/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java index ca17cbd2..3ec4732b 100644 --- a/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java @@ -710,7 +710,6 @@ public AutoTopupEnabledStage autoTopupAvailability( } /** - *

Derived from auto_topup_availability; use that instead.

*

Derived from auto_topup_availability; use that instead.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -722,7 +721,6 @@ public AutoTopupSelfServiceStage autoTopupEnabled(boolean autoTopupEnabled) { } /** - *

Derived from auto_topup_availability; use that instead.

*

Derived from auto_topup_availability; use that instead.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -734,7 +732,6 @@ public CanBuyBundlesStage autoTopupSelfService(boolean autoTopupSelfService) { } /** - *

Whether buyers can purchase one-time credit bundles on this grant, independent of auto top-up availability.

*

Whether buyers can purchase one-time credit bundles on this grant, independent of auto top-up availability.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -767,7 +764,6 @@ public CreditNameStage creditId(@NotNull String creditId) { } /** - *

Use credit.name from the nested credit object instead

*

Use credit.name from the nested credit object instead

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -793,7 +789,6 @@ public PlanNameStage planId(@NotNull String planId) { } /** - *

Use plan.name from the nested plan object instead

*

Use plan.name from the nested plan object instead

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -805,7 +800,6 @@ public RolloverPercentageStage planName(@NotNull String planName) { } /** - *

Percentage of unused credits that carry over when this grant resets. Only meaningful when reset_type is plan_period.

*

Percentage of unused credits that carry over when this grant resets. Only meaningful when reset_type is plan_period.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/CheckFlagResponseData.java b/src/main/java/com/schematic/api/types/CheckFlagResponseData.java index 60e4179b..d3dee469 100644 --- a/src/main/java/com/schematic/api/types/CheckFlagResponseData.java +++ b/src/main/java/com/schematic/api/types/CheckFlagResponseData.java @@ -440,7 +440,6 @@ public Builder from(CheckFlagResponseData other) { } /** - *

The key used to check the flag

*

The key used to check the flag

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -452,7 +451,6 @@ public ReasonStage flag(@NotNull String flag) { } /** - *

A human-readable explanation of the result

*

A human-readable explanation of the result

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -464,7 +462,6 @@ public ValueStage reason(@NotNull String reason) { } /** - *

A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted

*

A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/CompanyCreditBalance.java b/src/main/java/com/schematic/api/types/CompanyCreditBalance.java index e6507562..85a7aaf9 100644 --- a/src/main/java/com/schematic/api/types/CompanyCreditBalance.java +++ b/src/main/java/com/schematic/api/types/CompanyCreditBalance.java @@ -140,7 +140,6 @@ public Builder from(CompanyCreditBalance other) { } /** - *

Remaining credit, excluding any open lease hold (the value SDKs gate on)

*

Remaining credit, excluding any open lease hold (the value SDKs gate on)

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -152,7 +151,6 @@ public ReservedStage remaining(double remaining) { } /** - *

Amount held by the company's open credit lease, 0 when none is open

*

Amount held by the company's open credit lease, 0 when none is open

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -164,7 +162,6 @@ public SettledStage reserved(double reserved) { } /** - *

Spendable balance including the open lease hold (remaining + reserved)

*

Spendable balance including the open lease hold (remaining + reserved)

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/CompanyPlanCreditGrantView.java b/src/main/java/com/schematic/api/types/CompanyPlanCreditGrantView.java index 6ccf3a6b..abed3678 100644 --- a/src/main/java/com/schematic/api/types/CompanyPlanCreditGrantView.java +++ b/src/main/java/com/schematic/api/types/CompanyPlanCreditGrantView.java @@ -795,7 +795,6 @@ public CreditDescriptionStage creditAmount(long creditAmount) { } /** - *

Deprecated field, will be removed in the future. Use Credit.Description instead.

*

Deprecated field, will be removed in the future. Use Credit.Description instead.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -814,7 +813,6 @@ public CreditNameStage creditId(@NotNull String creditId) { } /** - *

Deprecated field, will be removed in the future. Use Credit.Name instead.

*

Deprecated field, will be removed in the future. Use Credit.Name instead.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java b/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java index f99fca34..03bc2e9c 100644 --- a/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java @@ -1007,7 +1007,6 @@ public IsFreeStage isDefault(boolean isDefault) { } /** - *

Deprecated: Use BillingStrategy instead

*

Deprecated: Use BillingStrategy instead

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/CreateEventRequestBody.java b/src/main/java/com/schematic/api/types/CreateEventRequestBody.java index a0efb2b8..bd05c9c6 100644 --- a/src/main/java/com/schematic/api/types/CreateEventRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateEventRequestBody.java @@ -213,7 +213,6 @@ public Builder from(CreateEventRequestBody other) { } /** - *

Either 'identify' or 'track'

*

Either 'identify' or 'track'

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/EventBody.java b/src/main/java/com/schematic/api/types/EventBody.java index 81af4845..6abd3703 100644 --- a/src/main/java/com/schematic/api/types/EventBody.java +++ b/src/main/java/com/schematic/api/types/EventBody.java @@ -38,6 +38,8 @@ public T visit(Visitor visitor) { return visitor.visit((EventBodyFlagCheck) this.value); } else if (this.type == 2) { return visitor.visit((EventBodyIdentify) this.value); + } else if (this.type == 3) { + return visitor.visit((EventBodyInference) this.value); } throw new IllegalStateException("Failed to visit value. This should never happen."); } @@ -74,12 +76,18 @@ public static EventBody of(EventBodyIdentify value) { return new EventBody(value, 2); } + public static EventBody of(EventBodyInference value) { + return new EventBody(value, 3); + } + public interface Visitor { T visit(EventBodyTrack value); T visit(EventBodyFlagCheck value); T visit(EventBodyIdentify value); + + T visit(EventBodyInference value); } static final class Deserializer extends StdDeserializer { @@ -111,6 +119,17 @@ public EventBody deserialize(JsonParser p, DeserializationContext context) throw } catch (RuntimeException e) { } } + if (value instanceof Map + && ((Map) value).containsKey("company") + && ((Map) value).containsKey("input_tokens") + && ((Map) value).containsKey("output_tokens") + && ((Map) value).containsKey("provider") + && ((Map) value).containsKey("response_model")) { + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventBodyInference.class)); + } catch (RuntimeException e) { + } + } throw new JsonParseException(p, "Failed to deserialize"); } } diff --git a/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java b/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java index 56c26d1a..391ee2c2 100644 --- a/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java +++ b/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java @@ -319,7 +319,6 @@ public Builder from(EventBodyFlagCheck other) { } /** - *

The key of the flag being checked

*

The key of the flag being checked

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -331,7 +330,6 @@ public ReasonStage flagKey(@NotNull String flagKey) { } /** - *

The reason why the value was returned

*

The reason why the value was returned

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -343,7 +341,6 @@ public ValueStage reason(@NotNull String reason) { } /** - *

The value of the flag for the given company and/or user

*

The value of the flag for the given company and/or user

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/EventBodyInference.java b/src/main/java/com/schematic/api/types/EventBodyInference.java new file mode 100644 index 00000000..876e1db7 --- /dev/null +++ b/src/main/java/com/schematic/api/types/EventBodyInference.java @@ -0,0 +1,712 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = EventBodyInference.Builder.class) +public final class EventBodyInference { + private final Optional cachedInputTokens; + + private final Map company; + + private final Optional cost; + + private final Optional currency; + + private final Optional event; + + private final long inputTokens; + + private final Optional operation; + + private final long outputTokens; + + private final String provider; + + private final Optional reasoningTokens; + + private final Optional requestModel; + + private final Optional requests; + + private final String responseModel; + + private final Optional> user; + + private final Map additionalProperties; + + private EventBodyInference( + Optional cachedInputTokens, + Map company, + Optional cost, + Optional currency, + Optional event, + long inputTokens, + Optional operation, + long outputTokens, + String provider, + Optional reasoningTokens, + Optional requestModel, + Optional requests, + String responseModel, + Optional> user, + Map additionalProperties) { + this.cachedInputTokens = cachedInputTokens; + this.company = company; + this.cost = cost; + this.currency = currency; + this.event = event; + this.inputTokens = inputTokens; + this.operation = operation; + this.outputTokens = outputTokens; + this.provider = provider; + this.reasoningTokens = reasoningTokens; + this.requestModel = requestModel; + this.requests = requests; + this.responseModel = responseModel; + this.user = user; + this.additionalProperties = additionalProperties; + } + + /** + * @return Number of input tokens served from cache + */ + @JsonProperty("cached_input_tokens") + public Optional getCachedInputTokens() { + return cachedInputTokens; + } + + /** + * @return Key-value pairs to identify the company associated with the inference event + */ + @JsonProperty("company") + public Map getCompany() { + return company; + } + + /** + * @return Provided cost of the inference request as a decimal string; derived from model pricing when omitted + */ + @JsonProperty("cost") + public Optional getCost() { + return cost; + } + + /** + * @return ISO 4217 currency code for the provided cost; defaults to 'usd' + */ + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + + /** + * @return Optional track event name to fan out for usage-based billing + */ + @JsonProperty("event") + public Optional getEvent() { + return event; + } + + /** + * @return Number of input tokens for the inference request + */ + @JsonProperty("input_tokens") + public long getInputTokens() { + return inputTokens; + } + + /** + * @return The inference operation; defaults to 'chat' + */ + @JsonProperty("operation") + public Optional getOperation() { + return operation; + } + + /** + * @return Number of output tokens for the inference request + */ + @JsonProperty("output_tokens") + public long getOutputTokens() { + return outputTokens; + } + + /** + * @return The inference provider (e.g. 'anthropic', 'openai') + */ + @JsonProperty("provider") + public String getProvider() { + return provider; + } + + /** + * @return Number of reasoning tokens for the inference request + */ + @JsonProperty("reasoning_tokens") + public Optional getReasoningTokens() { + return reasoningTokens; + } + + /** + * @return The model requested for the inference request + */ + @JsonProperty("request_model") + public Optional getRequestModel() { + return requestModel; + } + + /** + * @return Number of requests represented by this event; defaults to 1 + */ + @JsonProperty("requests") + public Optional getRequests() { + return requests; + } + + /** + * @return The model that served the inference response + */ + @JsonProperty("response_model") + public String getResponseModel() { + return responseModel; + } + + /** + * @return Key-value pairs to identify the user associated with the inference event + */ + @JsonProperty("user") + public Optional> getUser() { + return user; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EventBodyInference && equalTo((EventBodyInference) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EventBodyInference other) { + return cachedInputTokens.equals(other.cachedInputTokens) + && company.equals(other.company) + && cost.equals(other.cost) + && currency.equals(other.currency) + && event.equals(other.event) + && inputTokens == other.inputTokens + && operation.equals(other.operation) + && outputTokens == other.outputTokens + && provider.equals(other.provider) + && reasoningTokens.equals(other.reasoningTokens) + && requestModel.equals(other.requestModel) + && requests.equals(other.requests) + && responseModel.equals(other.responseModel) + && user.equals(other.user); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.cachedInputTokens, + this.company, + this.cost, + this.currency, + this.event, + this.inputTokens, + this.operation, + this.outputTokens, + this.provider, + this.reasoningTokens, + this.requestModel, + this.requests, + this.responseModel, + this.user); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InputTokensStage builder() { + return new Builder(); + } + + public interface InputTokensStage { + /** + *

Number of input tokens for the inference request

+ */ + OutputTokensStage inputTokens(long inputTokens); + + Builder from(EventBodyInference other); + } + + public interface OutputTokensStage { + /** + *

Number of output tokens for the inference request

+ */ + ProviderStage outputTokens(long outputTokens); + } + + public interface ProviderStage { + /** + *

The inference provider (e.g. 'anthropic', 'openai')

+ */ + ResponseModelStage provider(@NotNull String provider); + } + + public interface ResponseModelStage { + /** + *

The model that served the inference response

+ */ + _FinalStage responseModel(@NotNull String responseModel); + } + + public interface _FinalStage { + EventBodyInference build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Number of input tokens served from cache

+ */ + _FinalStage cachedInputTokens(Optional cachedInputTokens); + + _FinalStage cachedInputTokens(Long cachedInputTokens); + + /** + *

Key-value pairs to identify the company associated with the inference event

+ */ + _FinalStage company(Map company); + + _FinalStage putAllCompany(Map company); + + _FinalStage company(String key, String value); + + /** + *

Provided cost of the inference request as a decimal string; derived from model pricing when omitted

+ */ + _FinalStage cost(Optional cost); + + _FinalStage cost(String cost); + + /** + *

ISO 4217 currency code for the provided cost; defaults to 'usd'

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + + /** + *

Optional track event name to fan out for usage-based billing

+ */ + _FinalStage event(Optional event); + + _FinalStage event(String event); + + /** + *

The inference operation; defaults to 'chat'

+ */ + _FinalStage operation(Optional operation); + + _FinalStage operation(String operation); + + /** + *

Number of reasoning tokens for the inference request

+ */ + _FinalStage reasoningTokens(Optional reasoningTokens); + + _FinalStage reasoningTokens(Long reasoningTokens); + + /** + *

The model requested for the inference request

+ */ + _FinalStage requestModel(Optional requestModel); + + _FinalStage requestModel(String requestModel); + + /** + *

Number of requests represented by this event; defaults to 1

+ */ + _FinalStage requests(Optional requests); + + _FinalStage requests(Long requests); + + /** + *

Key-value pairs to identify the user associated with the inference event

+ */ + _FinalStage user(Optional> user); + + _FinalStage user(Map user); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements InputTokensStage, OutputTokensStage, ProviderStage, ResponseModelStage, _FinalStage { + private long inputTokens; + + private long outputTokens; + + private String provider; + + private String responseModel; + + private Optional> user = Optional.empty(); + + private Optional requests = Optional.empty(); + + private Optional requestModel = Optional.empty(); + + private Optional reasoningTokens = Optional.empty(); + + private Optional operation = Optional.empty(); + + private Optional event = Optional.empty(); + + private Optional currency = Optional.empty(); + + private Optional cost = Optional.empty(); + + private Map company = new LinkedHashMap<>(); + + private Optional cachedInputTokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(EventBodyInference other) { + cachedInputTokens(other.getCachedInputTokens()); + company(other.getCompany()); + cost(other.getCost()); + currency(other.getCurrency()); + event(other.getEvent()); + inputTokens(other.getInputTokens()); + operation(other.getOperation()); + outputTokens(other.getOutputTokens()); + provider(other.getProvider()); + reasoningTokens(other.getReasoningTokens()); + requestModel(other.getRequestModel()); + requests(other.getRequests()); + responseModel(other.getResponseModel()); + user(other.getUser()); + return this; + } + + /** + *

Number of input tokens for the inference request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("input_tokens") + public OutputTokensStage inputTokens(long inputTokens) { + this.inputTokens = inputTokens; + return this; + } + + /** + *

Number of output tokens for the inference request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("output_tokens") + public ProviderStage outputTokens(long outputTokens) { + this.outputTokens = outputTokens; + return this; + } + + /** + *

The inference provider (e.g. 'anthropic', 'openai')

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("provider") + public ResponseModelStage provider(@NotNull String provider) { + this.provider = Objects.requireNonNull(provider, "provider must not be null"); + return this; + } + + /** + *

The model that served the inference response

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("response_model") + public _FinalStage responseModel(@NotNull String responseModel) { + this.responseModel = Objects.requireNonNull(responseModel, "responseModel must not be null"); + return this; + } + + /** + *

Key-value pairs to identify the user associated with the inference event

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage user(Map user) { + this.user = Optional.ofNullable(user); + return this; + } + + /** + *

Key-value pairs to identify the user associated with the inference event

+ */ + @java.lang.Override + @JsonSetter(value = "user", nulls = Nulls.SKIP) + public _FinalStage user(Optional> user) { + this.user = user; + return this; + } + + /** + *

Number of requests represented by this event; defaults to 1

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage requests(Long requests) { + this.requests = Optional.ofNullable(requests); + return this; + } + + /** + *

Number of requests represented by this event; defaults to 1

+ */ + @java.lang.Override + @JsonSetter(value = "requests", nulls = Nulls.SKIP) + public _FinalStage requests(Optional requests) { + this.requests = requests; + return this; + } + + /** + *

The model requested for the inference request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage requestModel(String requestModel) { + this.requestModel = Optional.ofNullable(requestModel); + return this; + } + + /** + *

The model requested for the inference request

+ */ + @java.lang.Override + @JsonSetter(value = "request_model", nulls = Nulls.SKIP) + public _FinalStage requestModel(Optional requestModel) { + this.requestModel = requestModel; + return this; + } + + /** + *

Number of reasoning tokens for the inference request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage reasoningTokens(Long reasoningTokens) { + this.reasoningTokens = Optional.ofNullable(reasoningTokens); + return this; + } + + /** + *

Number of reasoning tokens for the inference request

+ */ + @java.lang.Override + @JsonSetter(value = "reasoning_tokens", nulls = Nulls.SKIP) + public _FinalStage reasoningTokens(Optional reasoningTokens) { + this.reasoningTokens = reasoningTokens; + return this; + } + + /** + *

The inference operation; defaults to 'chat'

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage operation(String operation) { + this.operation = Optional.ofNullable(operation); + return this; + } + + /** + *

The inference operation; defaults to 'chat'

+ */ + @java.lang.Override + @JsonSetter(value = "operation", nulls = Nulls.SKIP) + public _FinalStage operation(Optional operation) { + this.operation = operation; + return this; + } + + /** + *

Optional track event name to fan out for usage-based billing

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage event(String event) { + this.event = Optional.ofNullable(event); + return this; + } + + /** + *

Optional track event name to fan out for usage-based billing

+ */ + @java.lang.Override + @JsonSetter(value = "event", nulls = Nulls.SKIP) + public _FinalStage event(Optional event) { + this.event = event; + return this; + } + + /** + *

ISO 4217 currency code for the provided cost; defaults to 'usd'

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + /** + *

ISO 4217 currency code for the provided cost; defaults to 'usd'

+ */ + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + + /** + *

Provided cost of the inference request as a decimal string; derived from model pricing when omitted

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage cost(String cost) { + this.cost = Optional.ofNullable(cost); + return this; + } + + /** + *

Provided cost of the inference request as a decimal string; derived from model pricing when omitted

+ */ + @java.lang.Override + @JsonSetter(value = "cost", nulls = Nulls.SKIP) + public _FinalStage cost(Optional cost) { + this.cost = cost; + return this; + } + + /** + *

Key-value pairs to identify the company associated with the inference event

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage company(String key, String value) { + this.company.put(key, value); + return this; + } + + /** + *

Key-value pairs to identify the company associated with the inference event

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllCompany(Map company) { + if (company != null) { + this.company.putAll(company); + } + return this; + } + + /** + *

Key-value pairs to identify the company associated with the inference event

+ */ + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Map company) { + this.company.clear(); + if (company != null) { + this.company.putAll(company); + } + return this; + } + + /** + *

Number of input tokens served from cache

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage cachedInputTokens(Long cachedInputTokens) { + this.cachedInputTokens = Optional.ofNullable(cachedInputTokens); + return this; + } + + /** + *

Number of input tokens served from cache

+ */ + @java.lang.Override + @JsonSetter(value = "cached_input_tokens", nulls = Nulls.SKIP) + public _FinalStage cachedInputTokens(Optional cachedInputTokens) { + this.cachedInputTokens = cachedInputTokens; + return this; + } + + @java.lang.Override + public EventBodyInference build() { + return new EventBodyInference( + cachedInputTokens, + company, + cost, + currency, + event, + inputTokens, + operation, + outputTokens, + provider, + reasoningTokens, + requestModel, + requests, + responseModel, + user, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/EventBodyTrack.java b/src/main/java/com/schematic/api/types/EventBodyTrack.java index d4de364f..94b4adfe 100644 --- a/src/main/java/com/schematic/api/types/EventBodyTrack.java +++ b/src/main/java/com/schematic/api/types/EventBodyTrack.java @@ -218,7 +218,6 @@ public Builder from(EventBodyTrack other) { } /** - *

The name of the type of track event

*

The name of the type of track event

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/EventType.java b/src/main/java/com/schematic/api/types/EventType.java index f03bb918..deeb85d2 100644 --- a/src/main/java/com/schematic/api/types/EventType.java +++ b/src/main/java/com/schematic/api/types/EventType.java @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonValue; public final class EventType { + public static final EventType INFERENCE = new EventType(Value.INFERENCE, "inference"); + public static final EventType FLAG_CHECK = new EventType(Value.FLAG_CHECK, "flag_check"); public static final EventType TRACK = new EventType(Value.TRACK, "track"); @@ -44,6 +46,8 @@ public int hashCode() { public T visit(Visitor visitor) { switch (value) { + case INFERENCE: + return visitor.visitInference(); case FLAG_CHECK: return visitor.visitFlagCheck(); case TRACK: @@ -59,6 +63,8 @@ public T visit(Visitor visitor) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static EventType valueOf(String value) { switch (value) { + case "inference": + return INFERENCE; case "flag_check": return FLAG_CHECK; case "track": @@ -75,6 +81,8 @@ public enum Value { IDENTIFY, + INFERENCE, + TRACK, UNKNOWN @@ -85,6 +93,8 @@ public interface Visitor { T visitIdentify(); + T visitInference(); + T visitTrack(); T visitUnknown(String unknownType); diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java b/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java index e5113020..c436692a 100644 --- a/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java @@ -868,7 +868,6 @@ public Builder from(FeatureCompanyResponseData other) { } /** - *

Whether further usage is permitted.

*

Whether further usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -880,7 +879,6 @@ public AllocationTypeStage access(boolean access) { } /** - *

The type of allocation that is being used.

*

The type of allocation that is being used.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java b/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java index f3130137..d39f6dc8 100644 --- a/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java @@ -357,7 +357,6 @@ public Builder from(FeatureCompanyUserResponseData other) { } /** - *

Whether further usage is permitted.

*

Whether further usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -369,7 +368,6 @@ public AllocationTypeStage access(boolean access) { } /** - *

The type of allocation that is being used.

*

The type of allocation that is being used.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/FeatureEntitlement.java b/src/main/java/com/schematic/api/types/FeatureEntitlement.java index e2dedba2..9083b916 100644 --- a/src/main/java/com/schematic/api/types/FeatureEntitlement.java +++ b/src/main/java/com/schematic/api/types/FeatureEntitlement.java @@ -512,7 +512,6 @@ public Builder from(FeatureEntitlement other) { } /** - *

The ID of the feature

*

The ID of the feature

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -524,7 +523,6 @@ public FeatureKeyStage featureId(@NotNull String featureId) { } /** - *

The key of the flag associated with the feature

*

The key of the flag associated with the feature

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -536,7 +534,6 @@ public ValueTypeStage featureKey(@NotNull String featureKey) { } /** - *

The type of the entitlement value

*

The type of the entitlement value

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java b/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java index 3929d43d..7223adc0 100644 --- a/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java @@ -832,7 +832,6 @@ public Builder from(FeatureUsageResponseData other) { } /** - *

Whether further usage is permitted.

*

Whether further usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -844,7 +843,6 @@ public AllocationTypeStage access(boolean access) { } /** - *

The type of allocation that is being used.

*

The type of allocation that is being used.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/IntegrationsListResponseData.java b/src/main/java/com/schematic/api/types/IntegrationsListResponseData.java index 18d57786..6834441f 100644 --- a/src/main/java/com/schematic/api/types/IntegrationsListResponseData.java +++ b/src/main/java/com/schematic/api/types/IntegrationsListResponseData.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -31,6 +32,8 @@ public final class IntegrationsListResponseData { private final boolean isConnectInstall; + private final Optional lastWebhookReceivedAt; + private final IntegrationState state; private final IntegrationType type; @@ -43,6 +46,7 @@ private IntegrationsListResponseData( String id, boolean isAppInstall, boolean isConnectInstall, + Optional lastWebhookReceivedAt, IntegrationState state, IntegrationType type, Map additionalProperties) { @@ -51,6 +55,7 @@ private IntegrationsListResponseData( this.id = id; this.isAppInstall = isAppInstall; this.isConnectInstall = isConnectInstall; + this.lastWebhookReceivedAt = lastWebhookReceivedAt; this.state = state; this.type = type; this.additionalProperties = additionalProperties; @@ -81,6 +86,11 @@ public boolean getIsConnectInstall() { return isConnectInstall; } + @JsonProperty("last_webhook_received_at") + public Optional getLastWebhookReceivedAt() { + return lastWebhookReceivedAt; + } + @JsonProperty("state") public IntegrationState getState() { return state; @@ -108,6 +118,7 @@ private boolean equalTo(IntegrationsListResponseData other) { && id.equals(other.id) && isAppInstall == other.isAppInstall && isConnectInstall == other.isConnectInstall + && lastWebhookReceivedAt.equals(other.lastWebhookReceivedAt) && state.equals(other.state) && type.equals(other.type); } @@ -120,6 +131,7 @@ public int hashCode() { this.id, this.isAppInstall, this.isConnectInstall, + this.lastWebhookReceivedAt, this.state, this.type); } @@ -169,6 +181,10 @@ public interface _FinalStage { _FinalStage config(Optional config); _FinalStage config(IntegrationConfig config); + + _FinalStage lastWebhookReceivedAt(Optional lastWebhookReceivedAt); + + _FinalStage lastWebhookReceivedAt(OffsetDateTime lastWebhookReceivedAt); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -192,6 +208,8 @@ public static final class Builder private IntegrationType type; + private Optional lastWebhookReceivedAt = Optional.empty(); + private Optional config = Optional.empty(); @JsonAnySetter @@ -206,6 +224,7 @@ public Builder from(IntegrationsListResponseData other) { id(other.getId()); isAppInstall(other.getIsAppInstall()); isConnectInstall(other.getIsConnectInstall()); + lastWebhookReceivedAt(other.getLastWebhookReceivedAt()); state(other.getState()); type(other.getType()); return this; @@ -253,6 +272,19 @@ public _FinalStage type(@NotNull IntegrationType type) { return this; } + @java.lang.Override + public _FinalStage lastWebhookReceivedAt(OffsetDateTime lastWebhookReceivedAt) { + this.lastWebhookReceivedAt = Optional.ofNullable(lastWebhookReceivedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_webhook_received_at", nulls = Nulls.SKIP) + public _FinalStage lastWebhookReceivedAt(Optional lastWebhookReceivedAt) { + this.lastWebhookReceivedAt = lastWebhookReceivedAt; + return this; + } + @java.lang.Override public _FinalStage config(IntegrationConfig config) { this.config = Optional.ofNullable(config); @@ -269,7 +301,15 @@ public _FinalStage config(Optional config) { @java.lang.Override public IntegrationsListResponseData build() { return new IntegrationsListResponseData( - capabilities, config, id, isAppInstall, isConnectInstall, state, type, additionalProperties); + capabilities, + config, + id, + isAppInstall, + isConnectInstall, + lastWebhookReceivedAt, + state, + type, + additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/schematic/api/types/InvoiceRequestBody.java b/src/main/java/com/schematic/api/types/InvoiceRequestBody.java index 5785b8e9..50eff93d 100644 --- a/src/main/java/com/schematic/api/types/InvoiceRequestBody.java +++ b/src/main/java/com/schematic/api/types/InvoiceRequestBody.java @@ -36,8 +36,12 @@ public final class InvoiceRequestBody { private final Optional dueDate; + private final Optional endingBalance; + private final Optional paymentMethodExternalId; + private final Optional startingBalance; + private final Optional status; private final Optional subscriptionExternalId; @@ -56,7 +60,9 @@ private InvoiceRequestBody( String currency, String customerExternalId, Optional dueDate, + Optional endingBalance, Optional paymentMethodExternalId, + Optional startingBalance, Optional status, Optional subscriptionExternalId, long subtotal, @@ -69,7 +75,9 @@ private InvoiceRequestBody( this.currency = currency; this.customerExternalId = customerExternalId; this.dueDate = dueDate; + this.endingBalance = endingBalance; this.paymentMethodExternalId = paymentMethodExternalId; + this.startingBalance = startingBalance; this.status = status; this.subscriptionExternalId = subscriptionExternalId; this.subtotal = subtotal; @@ -112,11 +120,21 @@ public Optional getDueDate() { return dueDate; } + @JsonProperty("ending_balance") + public Optional getEndingBalance() { + return endingBalance; + } + @JsonProperty("payment_method_external_id") public Optional getPaymentMethodExternalId() { return paymentMethodExternalId; } + @JsonProperty("starting_balance") + public Optional getStartingBalance() { + return startingBalance; + } + @JsonProperty("status") public Optional getStatus() { return status; @@ -156,7 +174,9 @@ private boolean equalTo(InvoiceRequestBody other) { && currency.equals(other.currency) && customerExternalId.equals(other.customerExternalId) && dueDate.equals(other.dueDate) + && endingBalance.equals(other.endingBalance) && paymentMethodExternalId.equals(other.paymentMethodExternalId) + && startingBalance.equals(other.startingBalance) && status.equals(other.status) && subscriptionExternalId.equals(other.subscriptionExternalId) && subtotal == other.subtotal @@ -173,7 +193,9 @@ public int hashCode() { this.currency, this.customerExternalId, this.dueDate, + this.endingBalance, this.paymentMethodExternalId, + this.startingBalance, this.status, this.subscriptionExternalId, this.subtotal, @@ -230,10 +252,18 @@ public interface _FinalStage { _FinalStage dueDate(OffsetDateTime dueDate); + _FinalStage endingBalance(Optional endingBalance); + + _FinalStage endingBalance(Long endingBalance); + _FinalStage paymentMethodExternalId(Optional paymentMethodExternalId); _FinalStage paymentMethodExternalId(String paymentMethodExternalId); + _FinalStage startingBalance(Optional startingBalance); + + _FinalStage startingBalance(Long startingBalance); + _FinalStage status(Optional status); _FinalStage status(InvoiceStatus status); @@ -277,8 +307,12 @@ public static final class Builder private Optional status = Optional.empty(); + private Optional startingBalance = Optional.empty(); + private Optional paymentMethodExternalId = Optional.empty(); + private Optional endingBalance = Optional.empty(); + private Optional dueDate = Optional.empty(); @JsonAnySetter @@ -295,7 +329,9 @@ public Builder from(InvoiceRequestBody other) { currency(other.getCurrency()); customerExternalId(other.getCustomerExternalId()); dueDate(other.getDueDate()); + endingBalance(other.getEndingBalance()); paymentMethodExternalId(other.getPaymentMethodExternalId()); + startingBalance(other.getStartingBalance()); status(other.getStatus()); subscriptionExternalId(other.getSubscriptionExternalId()); subtotal(other.getSubtotal()); @@ -391,6 +427,19 @@ public _FinalStage status(Optional status) { return this; } + @java.lang.Override + public _FinalStage startingBalance(Long startingBalance) { + this.startingBalance = Optional.ofNullable(startingBalance); + return this; + } + + @java.lang.Override + @JsonSetter(value = "starting_balance", nulls = Nulls.SKIP) + public _FinalStage startingBalance(Optional startingBalance) { + this.startingBalance = startingBalance; + return this; + } + @java.lang.Override public _FinalStage paymentMethodExternalId(String paymentMethodExternalId) { this.paymentMethodExternalId = Optional.ofNullable(paymentMethodExternalId); @@ -404,6 +453,19 @@ public _FinalStage paymentMethodExternalId(Optional paymentMethodExterna return this; } + @java.lang.Override + public _FinalStage endingBalance(Long endingBalance) { + this.endingBalance = Optional.ofNullable(endingBalance); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ending_balance", nulls = Nulls.SKIP) + public _FinalStage endingBalance(Optional endingBalance) { + this.endingBalance = endingBalance; + return this; + } + @java.lang.Override public _FinalStage dueDate(OffsetDateTime dueDate) { this.dueDate = Optional.ofNullable(dueDate); @@ -427,7 +489,9 @@ public InvoiceRequestBody build() { currency, customerExternalId, dueDate, + endingBalance, paymentMethodExternalId, + startingBalance, status, subscriptionExternalId, subtotal, diff --git a/src/main/java/com/schematic/api/types/InvoiceResponseData.java b/src/main/java/com/schematic/api/types/InvoiceResponseData.java index 27002097..b5975087 100644 --- a/src/main/java/com/schematic/api/types/InvoiceResponseData.java +++ b/src/main/java/com/schematic/api/types/InvoiceResponseData.java @@ -40,6 +40,8 @@ public final class InvoiceResponseData { private final Optional dueDate; + private final long endingBalance; + private final String environmentId; private final Optional externalId; @@ -50,6 +52,8 @@ public final class InvoiceResponseData { private final BillingProviderType providerType; + private final long startingBalance; + private final Optional status; private final Optional subscriptionExternalId; @@ -72,11 +76,13 @@ private InvoiceResponseData( String currency, String customerExternalId, Optional dueDate, + long endingBalance, String environmentId, Optional externalId, String id, Optional paymentMethodExternalId, BillingProviderType providerType, + long startingBalance, Optional status, Optional subscriptionExternalId, long subtotal, @@ -92,11 +98,13 @@ private InvoiceResponseData( this.currency = currency; this.customerExternalId = customerExternalId; this.dueDate = dueDate; + this.endingBalance = endingBalance; this.environmentId = environmentId; this.externalId = externalId; this.id = id; this.paymentMethodExternalId = paymentMethodExternalId; this.providerType = providerType; + this.startingBalance = startingBalance; this.status = status; this.subscriptionExternalId = subscriptionExternalId; this.subtotal = subtotal; @@ -150,6 +158,11 @@ public Optional getDueDate() { return dueDate; } + @JsonProperty("ending_balance") + public long getEndingBalance() { + return endingBalance; + } + @JsonProperty("environment_id") public String getEnvironmentId() { return environmentId; @@ -175,6 +188,11 @@ public BillingProviderType getProviderType() { return providerType; } + @JsonProperty("starting_balance") + public long getStartingBalance() { + return startingBalance; + } + @JsonProperty("status") public Optional getStatus() { return status; @@ -221,11 +239,13 @@ private boolean equalTo(InvoiceResponseData other) { && currency.equals(other.currency) && customerExternalId.equals(other.customerExternalId) && dueDate.equals(other.dueDate) + && endingBalance == other.endingBalance && environmentId.equals(other.environmentId) && externalId.equals(other.externalId) && id.equals(other.id) && paymentMethodExternalId.equals(other.paymentMethodExternalId) && providerType.equals(other.providerType) + && startingBalance == other.startingBalance && status.equals(other.status) && subscriptionExternalId.equals(other.subscriptionExternalId) && subtotal == other.subtotal @@ -245,11 +265,13 @@ public int hashCode() { this.currency, this.customerExternalId, this.dueDate, + this.endingBalance, this.environmentId, this.externalId, this.id, this.paymentMethodExternalId, this.providerType, + this.startingBalance, this.status, this.subscriptionExternalId, this.subtotal, @@ -293,7 +315,11 @@ public interface CurrencyStage { } public interface CustomerExternalIdStage { - EnvironmentIdStage customerExternalId(@NotNull String customerExternalId); + EndingBalanceStage customerExternalId(@NotNull String customerExternalId); + } + + public interface EndingBalanceStage { + EnvironmentIdStage endingBalance(long endingBalance); } public interface EnvironmentIdStage { @@ -305,7 +331,11 @@ public interface IdStage { } public interface ProviderTypeStage { - SubtotalStage providerType(@NotNull BillingProviderType providerType); + StartingBalanceStage providerType(@NotNull BillingProviderType providerType); + } + + public interface StartingBalanceStage { + SubtotalStage startingBalance(long startingBalance); } public interface SubtotalStage { @@ -361,9 +391,11 @@ public static final class Builder CreatedAtStage, CurrencyStage, CustomerExternalIdStage, + EndingBalanceStage, EnvironmentIdStage, IdStage, ProviderTypeStage, + StartingBalanceStage, SubtotalStage, UpdatedAtStage, _FinalStage { @@ -381,12 +413,16 @@ public static final class Builder private String customerExternalId; + private long endingBalance; + private String environmentId; private String id; private BillingProviderType providerType; + private long startingBalance; + private long subtotal; private OffsetDateTime updatedAt; @@ -421,11 +457,13 @@ public Builder from(InvoiceResponseData other) { currency(other.getCurrency()); customerExternalId(other.getCustomerExternalId()); dueDate(other.getDueDate()); + endingBalance(other.getEndingBalance()); environmentId(other.getEnvironmentId()); externalId(other.getExternalId()); id(other.getId()); paymentMethodExternalId(other.getPaymentMethodExternalId()); providerType(other.getProviderType()); + startingBalance(other.getStartingBalance()); status(other.getStatus()); subscriptionExternalId(other.getSubscriptionExternalId()); subtotal(other.getSubtotal()); @@ -478,11 +516,18 @@ public CustomerExternalIdStage currency(@NotNull String currency) { @java.lang.Override @JsonSetter("customer_external_id") - public EnvironmentIdStage customerExternalId(@NotNull String customerExternalId) { + public EndingBalanceStage customerExternalId(@NotNull String customerExternalId) { this.customerExternalId = Objects.requireNonNull(customerExternalId, "customerExternalId must not be null"); return this; } + @java.lang.Override + @JsonSetter("ending_balance") + public EnvironmentIdStage endingBalance(long endingBalance) { + this.endingBalance = endingBalance; + return this; + } + @java.lang.Override @JsonSetter("environment_id") public IdStage environmentId(@NotNull String environmentId) { @@ -499,11 +544,18 @@ public ProviderTypeStage id(@NotNull String id) { @java.lang.Override @JsonSetter("provider_type") - public SubtotalStage providerType(@NotNull BillingProviderType providerType) { + public StartingBalanceStage providerType(@NotNull BillingProviderType providerType) { this.providerType = Objects.requireNonNull(providerType, "providerType must not be null"); return this; } + @java.lang.Override + @JsonSetter("starting_balance") + public SubtotalStage startingBalance(long startingBalance) { + this.startingBalance = startingBalance; + return this; + } + @java.lang.Override @JsonSetter("subtotal") public UpdatedAtStage subtotal(long subtotal) { @@ -621,11 +673,13 @@ public InvoiceResponseData build() { currency, customerExternalId, dueDate, + endingBalance, environmentId, externalId, id, paymentMethodExternalId, providerType, + startingBalance, status, subscriptionExternalId, subtotal, diff --git a/src/main/java/com/schematic/api/types/MetronomeIntegrationConfig.java b/src/main/java/com/schematic/api/types/MetronomeIntegrationConfig.java index 5d4e2ffd..243d70b6 100644 --- a/src/main/java/com/schematic/api/types/MetronomeIntegrationConfig.java +++ b/src/main/java/com/schematic/api/types/MetronomeIntegrationConfig.java @@ -7,24 +7,41 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; +import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = MetronomeIntegrationConfig.Builder.class) public final class MetronomeIntegrationConfig { + private final Optional externalCustomerIdKey; + private final Map additionalProperties; - private MetronomeIntegrationConfig(Map additionalProperties) { + private MetronomeIntegrationConfig( + Optional externalCustomerIdKey, Map additionalProperties) { + this.externalCustomerIdKey = externalCustomerIdKey; this.additionalProperties = additionalProperties; } + /** + * @return Schematic company key used to store the Metronome customer's ingest alias; when unset, imported customers carry only metronome_customer_id + */ + @JsonProperty("external_customer_id_key") + public Optional getExternalCustomerIdKey() { + return externalCustomerIdKey; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof MetronomeIntegrationConfig; + return other instanceof MetronomeIntegrationConfig && equalTo((MetronomeIntegrationConfig) other); } @JsonAnyGetter @@ -32,6 +49,15 @@ public Map getAdditionalProperties() { return this.additionalProperties; } + private boolean equalTo(MetronomeIntegrationConfig other) { + return externalCustomerIdKey.equals(other.externalCustomerIdKey); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.externalCustomerIdKey); + } + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); @@ -43,17 +69,34 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional externalCustomerIdKey = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(MetronomeIntegrationConfig other) { + externalCustomerIdKey(other.getExternalCustomerIdKey()); + return this; + } + + /** + *

Schematic company key used to store the Metronome customer's ingest alias; when unset, imported customers carry only metronome_customer_id

+ */ + @JsonSetter(value = "external_customer_id_key", nulls = Nulls.SKIP) + public Builder externalCustomerIdKey(Optional externalCustomerIdKey) { + this.externalCustomerIdKey = externalCustomerIdKey; + return this; + } + + public Builder externalCustomerIdKey(String externalCustomerIdKey) { + this.externalCustomerIdKey = Optional.ofNullable(externalCustomerIdKey); return this; } public MetronomeIntegrationConfig build() { - return new MetronomeIntegrationConfig(additionalProperties); + return new MetronomeIntegrationConfig(externalCustomerIdKey, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/schematic/api/types/PlanBundleResponseData.java b/src/main/java/com/schematic/api/types/PlanBundleResponseData.java index 82e59a5b..015a91d9 100644 --- a/src/main/java/com/schematic/api/types/PlanBundleResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanBundleResponseData.java @@ -29,8 +29,6 @@ public final class PlanBundleResponseData { private final Optional plan; - private final Optional> traits; - private final Map additionalProperties; private PlanBundleResponseData( @@ -38,13 +36,11 @@ private PlanBundleResponseData( Optional> creditGrants, Optional> entitlements, Optional plan, - Optional> traits, Map additionalProperties) { this.billingProduct = billingProduct; this.creditGrants = creditGrants; this.entitlements = entitlements; this.plan = plan; - this.traits = traits; this.additionalProperties = additionalProperties; } @@ -68,11 +64,6 @@ public Optional getPlan() { return plan; } - @JsonProperty("traits") - public Optional> getTraits() { - return traits; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -88,13 +79,12 @@ private boolean equalTo(PlanBundleResponseData other) { return billingProduct.equals(other.billingProduct) && creditGrants.equals(other.creditGrants) && entitlements.equals(other.entitlements) - && plan.equals(other.plan) - && traits.equals(other.traits); + && plan.equals(other.plan); } @java.lang.Override public int hashCode() { - return Objects.hash(this.billingProduct, this.creditGrants, this.entitlements, this.plan, this.traits); + return Objects.hash(this.billingProduct, this.creditGrants, this.entitlements, this.plan); } @java.lang.Override @@ -116,8 +106,6 @@ public static final class Builder { private Optional plan = Optional.empty(); - private Optional> traits = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -128,7 +116,6 @@ public Builder from(PlanBundleResponseData other) { creditGrants(other.getCreditGrants()); entitlements(other.getEntitlements()); plan(other.getPlan()); - traits(other.getTraits()); return this; } @@ -176,20 +163,8 @@ public Builder plan(PlanResponseData plan) { return this; } - @JsonSetter(value = "traits", nulls = Nulls.SKIP) - public Builder traits(Optional> traits) { - this.traits = traits; - return this; - } - - public Builder traits(List traits) { - this.traits = Optional.ofNullable(traits); - return this; - } - public PlanBundleResponseData build() { - return new PlanBundleResponseData( - billingProduct, creditGrants, entitlements, plan, traits, additionalProperties); + return new PlanBundleResponseData(billingProduct, creditGrants, entitlements, plan, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseData.java b/src/main/java/com/schematic/api/types/PlanChangeResponseData.java index 543b3d36..43c81e5b 100644 --- a/src/main/java/com/schematic/api/types/PlanChangeResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseData.java @@ -613,7 +613,6 @@ public IsVersionUpgradeStage id(@NotNull String id) { } /** - *

True when this change moved the company to a different version of the same plan (e.g. a plan version migration) rather than to a different plan.

*

True when this change moved the company to a different version of the same plan (e.g. a plan version migration) rather than to a different plan.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/PlanCreditGrantView.java b/src/main/java/com/schematic/api/types/PlanCreditGrantView.java index 2bfda7bd..6228eddb 100644 --- a/src/main/java/com/schematic/api/types/PlanCreditGrantView.java +++ b/src/main/java/com/schematic/api/types/PlanCreditGrantView.java @@ -741,7 +741,6 @@ public CreditDescriptionStage creditAmount(long creditAmount) { } /** - *

Deprecated field, will be removed in the future. Use Credit.Description instead.

*

Deprecated field, will be removed in the future. Use Credit.Description instead.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -760,7 +759,6 @@ public CreditNameStage creditId(@NotNull String creditId) { } /** - *

Deprecated field, will be removed in the future. Use Credit.Name instead.

*

Deprecated field, will be removed in the future. Use Credit.Name instead.

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/PlanDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanDetailResponseData.java index 0cb96b96..1515c0a0 100644 --- a/src/main/java/com/schematic/api/types/PlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanDetailResponseData.java @@ -786,7 +786,6 @@ public IsFreeStage isDefault(boolean isDefault) { } /** - *

Deprecated: Use BillingStrategy instead

*

Deprecated: Use BillingStrategy instead

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java b/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java index e868b60f..e03fbbbc 100644 --- a/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java @@ -82,6 +82,8 @@ public final class PlanEntitlementResponseData { private final EntitlementValueType valueType; + private final List warningTiers; + private final Map additionalProperties; private PlanEntitlementResponseData( @@ -114,6 +116,7 @@ private PlanEntitlementResponseData( Optional valueTrait, Optional valueTraitId, EntitlementValueType valueType, + List warningTiers, Map additionalProperties) { this.billingLinkedResource = billingLinkedResource; this.billingThreshold = billingThreshold; @@ -144,6 +147,7 @@ private PlanEntitlementResponseData( this.valueTrait = valueTrait; this.valueTraitId = valueTraitId; this.valueType = valueType; + this.warningTiers = warningTiers; this.additionalProperties = additionalProperties; } @@ -295,6 +299,11 @@ public EntitlementValueType getValueType() { return valueType; } + @JsonProperty("warning_tiers") + public List getWarningTiers() { + return warningTiers; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -335,7 +344,8 @@ private boolean equalTo(PlanEntitlementResponseData other) { && valueNumeric.equals(other.valueNumeric) && valueTrait.equals(other.valueTrait) && valueTraitId.equals(other.valueTraitId) - && valueType.equals(other.valueType); + && valueType.equals(other.valueType) + && warningTiers.equals(other.warningTiers); } @java.lang.Override @@ -369,7 +379,8 @@ public int hashCode() { this.valueNumeric, this.valueTrait, this.valueTraitId, - this.valueType); + this.valueType, + this.warningTiers); } @java.lang.Override @@ -510,6 +521,12 @@ public interface _FinalStage { _FinalStage valueTraitId(Optional valueTraitId); _FinalStage valueTraitId(String valueTraitId); + + _FinalStage warningTiers(List warningTiers); + + _FinalStage addWarningTiers(WarningTierResponseData warningTiers); + + _FinalStage addAllWarningTiers(List warningTiers); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -539,6 +556,8 @@ public static final class Builder private EntitlementValueType valueType; + private List warningTiers = new ArrayList<>(); + private Optional valueTraitId = Optional.empty(); private Optional valueTrait = Optional.empty(); @@ -617,6 +636,7 @@ public Builder from(PlanEntitlementResponseData other) { valueTrait(other.getValueTrait()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); + warningTiers(other.getWarningTiers()); return this; } @@ -676,6 +696,30 @@ public _FinalStage valueType(@NotNull EntitlementValueType valueType) { return this; } + @java.lang.Override + public _FinalStage addAllWarningTiers(List warningTiers) { + if (warningTiers != null) { + this.warningTiers.addAll(warningTiers); + } + return this; + } + + @java.lang.Override + public _FinalStage addWarningTiers(WarningTierResponseData warningTiers) { + this.warningTiers.add(warningTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "warning_tiers", nulls = Nulls.SKIP) + public _FinalStage warningTiers(List warningTiers) { + this.warningTiers.clear(); + if (warningTiers != null) { + this.warningTiers.addAll(warningTiers); + } + return this; + } + @java.lang.Override public _FinalStage valueTraitId(String valueTraitId) { this.valueTraitId = Optional.ofNullable(valueTraitId); @@ -999,6 +1043,7 @@ public PlanEntitlementResponseData build() { valueTrait, valueTraitId, valueType, + warningTiers, additionalProperties); } diff --git a/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java index 79ae7a8b..5f57ff14 100644 --- a/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java @@ -870,7 +870,6 @@ public IsFreeStage isDefault(boolean isDefault) { } /** - *

Deprecated: Use BillingStrategy instead

*

Deprecated: Use BillingStrategy instead

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java b/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java index be02eb4b..f004241f 100644 --- a/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanViewPublicResponseData.java @@ -898,7 +898,6 @@ public IsFreeStage isDefault(boolean isDefault) { } /** - *

Deprecated: Use BillingStrategy instead

*

Deprecated: Use BillingStrategy instead

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/RulesengineFeatureEntitlement.java b/src/main/java/com/schematic/api/types/RulesengineFeatureEntitlement.java index 0f3b433b..5a544bef 100644 --- a/src/main/java/com/schematic/api/types/RulesengineFeatureEntitlement.java +++ b/src/main/java/com/schematic/api/types/RulesengineFeatureEntitlement.java @@ -512,7 +512,6 @@ public Builder from(RulesengineFeatureEntitlement other) { } /** - *

The ID of the feature

*

The ID of the feature

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -524,7 +523,6 @@ public FeatureKeyStage featureId(@NotNull String featureId) { } /** - *

The key of the flag associated with the feature

*

The key of the flag associated with the feature

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -536,7 +534,6 @@ public ValueTypeStage featureKey(@NotNull String featureKey) { } /** - *

The type of the entitlement value

*

The type of the entitlement value

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java b/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java index 07480b00..32ca1ee6 100644 --- a/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java +++ b/src/main/java/com/schematic/api/types/StripeIntegrationConfig.java @@ -222,7 +222,6 @@ public Builder from(StripeIntegrationConfig other) { } /** - *

Whether the integration is connected to a Stripe sandbox account

*

Whether the integration is connected to a Stripe sandbox account

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -234,7 +233,6 @@ public LiveModeStage isSandbox(boolean isSandbox) { } /** - *

Whether the integration is connected to a live Stripe account

*

Whether the integration is connected to a live Stripe account

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java b/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java index b3395d69..29fadda1 100644 --- a/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java @@ -197,7 +197,6 @@ public Builder from(UpsertTraitRequestBody other) { } /** - *

Name of the trait to update

*

Name of the trait to update

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/WarningTierRequestBody.java b/src/main/java/com/schematic/api/types/WarningTierRequestBody.java new file mode 100644 index 00000000..8e03b78c --- /dev/null +++ b/src/main/java/com/schematic/api/types/WarningTierRequestBody.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = WarningTierRequestBody.Builder.class) +public final class WarningTierRequestBody { + private final String key; + + private final long value; + + private final Map additionalProperties; + + private WarningTierRequestBody(String key, long value, Map additionalProperties) { + this.key = key; + this.value = value; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("value") + public long getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof WarningTierRequestBody && equalTo((WarningTierRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(WarningTierRequestBody other) { + return key.equals(other.key) && value == other.value; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.key, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static KeyStage builder() { + return new Builder(); + } + + public interface KeyStage { + ValueStage key(@NotNull String key); + + Builder from(WarningTierRequestBody other); + } + + public interface ValueStage { + _FinalStage value(long value); + } + + public interface _FinalStage { + WarningTierRequestBody build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements KeyStage, ValueStage, _FinalStage { + private String key; + + private long value; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(WarningTierRequestBody other) { + key(other.getKey()); + value(other.getValue()); + return this; + } + + @java.lang.Override + @JsonSetter("key") + public ValueStage key(@NotNull String key) { + this.key = Objects.requireNonNull(key, "key must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(long value) { + this.value = value; + return this; + } + + @java.lang.Override + public WarningTierRequestBody build() { + return new WarningTierRequestBody(key, value, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/schematic/api/types/WarningTierResponseData.java b/src/main/java/com/schematic/api/types/WarningTierResponseData.java new file mode 100644 index 00000000..a8716dce --- /dev/null +++ b/src/main/java/com/schematic/api/types/WarningTierResponseData.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = WarningTierResponseData.Builder.class) +public final class WarningTierResponseData { + private final String id; + + private final String key; + + private final long value; + + private final Map additionalProperties; + + private WarningTierResponseData(String id, String key, long value, Map additionalProperties) { + this.id = id; + this.key = key; + this.value = value; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("value") + public long getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof WarningTierResponseData && equalTo((WarningTierResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(WarningTierResponseData other) { + return id.equals(other.id) && key.equals(other.key) && value == other.value; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.key, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + KeyStage id(@NotNull String id); + + Builder from(WarningTierResponseData other); + } + + public interface KeyStage { + ValueStage key(@NotNull String key); + } + + public interface ValueStage { + _FinalStage value(long value); + } + + public interface _FinalStage { + WarningTierResponseData build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, KeyStage, ValueStage, _FinalStage { + private String id; + + private String key; + + private long value; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(WarningTierResponseData other) { + id(other.getId()); + key(other.getKey()); + value(other.getValue()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public KeyStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("key") + public ValueStage key(@NotNull String key) { + this.key = Objects.requireNonNull(key, "key must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(long value) { + this.value = value; + return this; + } + + @java.lang.Override + public WarningTierResponseData build() { + return new WarningTierResponseData(id, key, value, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/test/java/com/schematic/api/UndiscriminatedUnionTest.java b/src/test/java/com/schematic/api/UndiscriminatedUnionTest.java index 2980b0f6..6664d74b 100644 --- a/src/test/java/com/schematic/api/UndiscriminatedUnionTest.java +++ b/src/test/java/com/schematic/api/UndiscriminatedUnionTest.java @@ -9,6 +9,7 @@ import com.schematic.api.types.EventBody; import com.schematic.api.types.EventBodyFlagCheck; import com.schematic.api.types.EventBodyIdentify; +import com.schematic.api.types.EventBodyInference; import com.schematic.api.types.EventBodyTrack; import org.junit.jupiter.api.Test; @@ -33,4 +34,12 @@ public void testEventBody_EventBodyIdentify() throws Exception { EventBody union = ObjectMappers.JSON_MAPPER.readValue(json, EventBody.class); assertTrue(union.get() instanceof EventBodyIdentify, "Expected EventBodyIdentify but got different variant"); } + + @Test + public void testEventBody_EventBodyInference() throws Exception { + String json = + "{\"company\":{},\"input_tokens\":1,\"output_tokens\":1,\"provider\":\"test\",\"response_model\":\"test\"}"; + EventBody union = ObjectMappers.JSON_MAPPER.readValue(json, EventBody.class); + assertTrue(union.get() instanceof EventBodyInference, "Expected EventBodyInference but got different variant"); + } } From 6fea51fbe5e3d08053bb56e8a2ed3f8db7ce286f Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:55:25 +0000 Subject: [PATCH 2/2] [fern-replay] advance lockfile --- .fern/replay.lock | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.fern/replay.lock b/.fern/replay.lock index 68eff774..425912e1 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -6,5 +6,11 @@ generations: timestamp: 2026-05-25T11:22:32.078Z cli_version: unknown generator_versions: {} -current_generation: 27876f527547fe93937ca0c57e06af8c48b0b3d3 + - commit_sha: 6f0570857c48dde6c3e66bba48c4846907746994 + tree_hash: 38132d7692fd17f6d65764e4ecc22ec6f68fcce7 + timestamp: 2026-07-14T14:55:22.408Z + cli_version: unknown + generator_versions: + fernapi/fern-java-sdk: 4.11.1 +current_generation: 6f0570857c48dde6c3e66bba48c4846907746994 patches: []