diff --git a/algoliasearch/src/main/java/com/algolia/api/AbtestingClient.java b/algoliasearch/src/main/java/com/algolia/api/AbtestingClient.java index 4116916c8..e12cf180a 100644 --- a/algoliasearch/src/main/java/com/algolia/api/AbtestingClient.java +++ b/algoliasearch/src/main/java/com/algolia/api/AbtestingClient.java @@ -748,6 +748,58 @@ public CompletableFuture listABTestsAsync() throws AlgoliaR return this.listABTestsAsync(null, null, null, null, null); } + /** + * Schedule an A/B test to be started at a later time. + * + * @param scheduleABTestsRequest (required) + * @param requestOptions The requestOptions to send along with the query, they will be merged with + * the transporter requestOptions. + * @throws AlgoliaRuntimeException If it fails to process the API call + */ + public ScheduleABTestResponse scheduleABTest(@Nonnull ScheduleABTestsRequest scheduleABTestsRequest, RequestOptions requestOptions) + throws AlgoliaRuntimeException { + return LaunderThrowable.await(scheduleABTestAsync(scheduleABTestsRequest, requestOptions)); + } + + /** + * Schedule an A/B test to be started at a later time. + * + * @param scheduleABTestsRequest (required) + * @throws AlgoliaRuntimeException If it fails to process the API call + */ + public ScheduleABTestResponse scheduleABTest(@Nonnull ScheduleABTestsRequest scheduleABTestsRequest) throws AlgoliaRuntimeException { + return this.scheduleABTest(scheduleABTestsRequest, null); + } + + /** + * (asynchronously) Schedule an A/B test to be started at a later time. + * + * @param scheduleABTestsRequest (required) + * @param requestOptions The requestOptions to send along with the query, they will be merged with + * the transporter requestOptions. + * @throws AlgoliaRuntimeException If it fails to process the API call + */ + public CompletableFuture scheduleABTestAsync( + @Nonnull ScheduleABTestsRequest scheduleABTestsRequest, + RequestOptions requestOptions + ) throws AlgoliaRuntimeException { + Parameters.requireNonNull(scheduleABTestsRequest, "Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`."); + + HttpRequest request = HttpRequest.builder().setPath("/2/abtests/schedule").setMethod("POST").setBody(scheduleABTestsRequest).build(); + return executeAsync(request, requestOptions, new TypeReference() {}); + } + + /** + * (asynchronously) Schedule an A/B test to be started at a later time. + * + * @param scheduleABTestsRequest (required) + * @throws AlgoliaRuntimeException If it fails to process the API call + */ + public CompletableFuture scheduleABTestAsync(@Nonnull ScheduleABTestsRequest scheduleABTestsRequest) + throws AlgoliaRuntimeException { + return this.scheduleABTestAsync(scheduleABTestsRequest, null); + } + /** * Stops an A/B test by its ID. You can't restart stopped A/B tests. * diff --git a/algoliasearch/src/main/java/com/algolia/model/abtesting/ScheduleABTestResponse.java b/algoliasearch/src/main/java/com/algolia/model/abtesting/ScheduleABTestResponse.java new file mode 100644 index 000000000..66748e73d --- /dev/null +++ b/algoliasearch/src/main/java/com/algolia/model/abtesting/ScheduleABTestResponse.java @@ -0,0 +1,62 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost +// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +package com.algolia.model.abtesting; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.*; +import java.util.Objects; + +/** ScheduleABTestResponse */ +public class ScheduleABTestResponse { + + @JsonProperty("abTestScheduleID") + private Integer abTestScheduleID; + + public ScheduleABTestResponse setAbTestScheduleID(Integer abTestScheduleID) { + this.abTestScheduleID = abTestScheduleID; + return this; + } + + /** Unique scheduled A/B test identifier. */ + @javax.annotation.Nonnull + public Integer getAbTestScheduleID() { + return abTestScheduleID; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScheduleABTestResponse scheduleABTestResponse = (ScheduleABTestResponse) o; + return Objects.equals(this.abTestScheduleID, scheduleABTestResponse.abTestScheduleID); + } + + @Override + public int hashCode() { + return Objects.hash(abTestScheduleID); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScheduleABTestResponse {\n"); + sb.append(" abTestScheduleID: ").append(toIndentedString(abTestScheduleID)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/algoliasearch/src/main/java/com/algolia/model/abtesting/ScheduleABTestsRequest.java b/algoliasearch/src/main/java/com/algolia/model/abtesting/ScheduleABTestsRequest.java new file mode 100644 index 000000000..488f89bc7 --- /dev/null +++ b/algoliasearch/src/main/java/com/algolia/model/abtesting/ScheduleABTestsRequest.java @@ -0,0 +1,119 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost +// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +package com.algolia.model.abtesting; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ScheduleABTestsRequest */ +public class ScheduleABTestsRequest { + + @JsonProperty("name") + private String name; + + @JsonProperty("variants") + private List variants = new ArrayList<>(); + + @JsonProperty("scheduledAt") + private String scheduledAt; + + @JsonProperty("endAt") + private String endAt; + + public ScheduleABTestsRequest setName(String name) { + this.name = name; + return this; + } + + /** A/B test name. */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public ScheduleABTestsRequest setVariants(List variants) { + this.variants = variants; + return this; + } + + public ScheduleABTestsRequest addVariants(AddABTestsVariant variantsItem) { + this.variants.add(variantsItem); + return this; + } + + /** A/B test variants. */ + @javax.annotation.Nonnull + public List getVariants() { + return variants; + } + + public ScheduleABTestsRequest setScheduledAt(String scheduledAt) { + this.scheduledAt = scheduledAt; + return this; + } + + /** Date and time when the A/B test is scheduled to start, in RFC 3339 format. */ + @javax.annotation.Nonnull + public String getScheduledAt() { + return scheduledAt; + } + + public ScheduleABTestsRequest setEndAt(String endAt) { + this.endAt = endAt; + return this; + } + + /** End date and time of the A/B test, in RFC 3339 format. */ + @javax.annotation.Nonnull + public String getEndAt() { + return endAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScheduleABTestsRequest scheduleABTestsRequest = (ScheduleABTestsRequest) o; + return ( + Objects.equals(this.name, scheduleABTestsRequest.name) && + Objects.equals(this.variants, scheduleABTestsRequest.variants) && + Objects.equals(this.scheduledAt, scheduleABTestsRequest.scheduledAt) && + Objects.equals(this.endAt, scheduleABTestsRequest.endAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(name, variants, scheduledAt, endAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScheduleABTestsRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" variants: ").append(toIndentedString(variants)).append("\n"); + sb.append(" scheduledAt: ").append(toIndentedString(scheduledAt)).append("\n"); + sb.append(" endAt: ").append(toIndentedString(endAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +}