Skip to content

Commit

Permalink
feat(specs): add /schedule endpoint (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3350

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Fernando Beck <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
3 people committed Aug 20, 2024
1 parent 50c69c1 commit b3cf1a0
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 0 deletions.
52 changes: 52 additions & 0 deletions algoliasearch/src/main/java/com/algolia/api/AbtestingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,58 @@ public CompletableFuture<ListABTestsResponse> 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<ScheduleABTestResponse> 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<ScheduleABTestResponse>() {});
}

/**
* (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<ScheduleABTestResponse> 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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ");
}
}
Original file line number Diff line number Diff line change
@@ -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<AddABTestsVariant> 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<AddABTestsVariant> 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<AddABTestsVariant> 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 ");
}
}

0 comments on commit b3cf1a0

Please sign in to comment.