Skip to content

Commit f7a6ebc

Browse files
algolia-botcdhawkemillotp
committed
feat(specs): add estimate path and responses [skip-bc] (generated)
algolia/api-clients-automation#4057 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Christopher Hawke <69921547+cdhawke@users.noreply.github.com> Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent 379e726 commit f7a6ebc

File tree

6 files changed

+363
-16
lines changed

6 files changed

+363
-16
lines changed

algoliasearch/src/main/java/com/algolia/api/AbtestingClient.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,62 @@ public CompletableFuture<ABTestResponse> deleteABTestAsync(@Nonnull Integer id)
574574
return this.deleteABTestAsync(id, null);
575575
}
576576

577+
/**
578+
* Given the traffic percentage and the expected effect size, this endpoint estimates the sample
579+
* size and duration of an A/B test based on historical traffic.
580+
*
581+
* @param estimateABTestRequest (required)
582+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
583+
* the transporter requestOptions.
584+
* @throws AlgoliaRuntimeException If it fails to process the API call
585+
*/
586+
public EstimateABTestResponse estimateABTest(@Nonnull EstimateABTestRequest estimateABTestRequest, RequestOptions requestOptions)
587+
throws AlgoliaRuntimeException {
588+
return LaunderThrowable.await(estimateABTestAsync(estimateABTestRequest, requestOptions));
589+
}
590+
591+
/**
592+
* Given the traffic percentage and the expected effect size, this endpoint estimates the sample
593+
* size and duration of an A/B test based on historical traffic.
594+
*
595+
* @param estimateABTestRequest (required)
596+
* @throws AlgoliaRuntimeException If it fails to process the API call
597+
*/
598+
public EstimateABTestResponse estimateABTest(@Nonnull EstimateABTestRequest estimateABTestRequest) throws AlgoliaRuntimeException {
599+
return this.estimateABTest(estimateABTestRequest, null);
600+
}
601+
602+
/**
603+
* (asynchronously) Given the traffic percentage and the expected effect size, this endpoint
604+
* estimates the sample size and duration of an A/B test based on historical traffic.
605+
*
606+
* @param estimateABTestRequest (required)
607+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
608+
* the transporter requestOptions.
609+
* @throws AlgoliaRuntimeException If it fails to process the API call
610+
*/
611+
public CompletableFuture<EstimateABTestResponse> estimateABTestAsync(
612+
@Nonnull EstimateABTestRequest estimateABTestRequest,
613+
RequestOptions requestOptions
614+
) throws AlgoliaRuntimeException {
615+
Parameters.requireNonNull(estimateABTestRequest, "Parameter `estimateABTestRequest` is required when calling `estimateABTest`.");
616+
617+
HttpRequest request = HttpRequest.builder().setPath("/2/abtests/estimate").setMethod("POST").setBody(estimateABTestRequest).build();
618+
return executeAsync(request, requestOptions, new TypeReference<EstimateABTestResponse>() {});
619+
}
620+
621+
/**
622+
* (asynchronously) Given the traffic percentage and the expected effect size, this endpoint
623+
* estimates the sample size and duration of an A/B test based on historical traffic.
624+
*
625+
* @param estimateABTestRequest (required)
626+
* @throws AlgoliaRuntimeException If it fails to process the API call
627+
*/
628+
public CompletableFuture<EstimateABTestResponse> estimateABTestAsync(@Nonnull EstimateABTestRequest estimateABTestRequest)
629+
throws AlgoliaRuntimeException {
630+
return this.estimateABTestAsync(estimateABTestRequest, null);
631+
}
632+
577633
/**
578634
* Retrieves the details for an A/B test by its ID.
579635
*

algoliasearch/src/main/java/com/algolia/model/abtesting/Effect.java renamed to algoliasearch/src/main/java/com/algolia/model/abtesting/EffectMetric.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.fasterxml.jackson.databind.annotation.*;
88

99
/** Metric for which you want to detect the smallest relative difference. */
10-
public enum Effect {
10+
public enum EffectMetric {
1111
ADD_TO_CART_RATE("addToCartRate"),
1212

1313
CLICK_THROUGH_RATE("clickThroughRate"),
@@ -18,7 +18,7 @@ public enum Effect {
1818

1919
private final String value;
2020

21-
Effect(String value) {
21+
EffectMetric(String value) {
2222
this.value = value;
2323
}
2424

@@ -33,8 +33,8 @@ public String toString() {
3333
}
3434

3535
@JsonCreator
36-
public static Effect fromValue(String value) {
37-
for (Effect b : Effect.values()) {
36+
public static EffectMetric fromValue(String value) {
37+
for (EffectMetric b : EffectMetric.values()) {
3838
if (b.value.equals(value)) {
3939
return b;
4040
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.abtesting;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
import java.util.Objects;
11+
12+
/** EstimateABTestRequest */
13+
public class EstimateABTestRequest {
14+
15+
@JsonProperty("configuration")
16+
private EstimateConfiguration configuration;
17+
18+
@JsonProperty("variants")
19+
private List<AddABTestsVariant> variants = new ArrayList<>();
20+
21+
public EstimateABTestRequest setConfiguration(EstimateConfiguration configuration) {
22+
this.configuration = configuration;
23+
return this;
24+
}
25+
26+
/** Get configuration */
27+
@javax.annotation.Nonnull
28+
public EstimateConfiguration getConfiguration() {
29+
return configuration;
30+
}
31+
32+
public EstimateABTestRequest setVariants(List<AddABTestsVariant> variants) {
33+
this.variants = variants;
34+
return this;
35+
}
36+
37+
public EstimateABTestRequest addVariants(AddABTestsVariant variantsItem) {
38+
this.variants.add(variantsItem);
39+
return this;
40+
}
41+
42+
/** A/B test variants. */
43+
@javax.annotation.Nonnull
44+
public List<AddABTestsVariant> getVariants() {
45+
return variants;
46+
}
47+
48+
@Override
49+
public boolean equals(Object o) {
50+
if (this == o) {
51+
return true;
52+
}
53+
if (o == null || getClass() != o.getClass()) {
54+
return false;
55+
}
56+
EstimateABTestRequest estimateABTestRequest = (EstimateABTestRequest) o;
57+
return (
58+
Objects.equals(this.configuration, estimateABTestRequest.configuration) &&
59+
Objects.equals(this.variants, estimateABTestRequest.variants)
60+
);
61+
}
62+
63+
@Override
64+
public int hashCode() {
65+
return Objects.hash(configuration, variants);
66+
}
67+
68+
@Override
69+
public String toString() {
70+
StringBuilder sb = new StringBuilder();
71+
sb.append("class EstimateABTestRequest {\n");
72+
sb.append(" configuration: ").append(toIndentedString(configuration)).append("\n");
73+
sb.append(" variants: ").append(toIndentedString(variants)).append("\n");
74+
sb.append("}");
75+
return sb.toString();
76+
}
77+
78+
/**
79+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
80+
*/
81+
private String toIndentedString(Object o) {
82+
if (o == null) {
83+
return "null";
84+
}
85+
return o.toString().replace("\n", "\n ");
86+
}
87+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.abtesting;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.Objects;
9+
10+
/** EstimateABTestResponse */
11+
public class EstimateABTestResponse {
12+
13+
@JsonProperty("durationDays")
14+
private Long durationDays;
15+
16+
@JsonProperty("controlSampleSize")
17+
private Long controlSampleSize;
18+
19+
@JsonProperty("experimentSampleSize")
20+
private Long experimentSampleSize;
21+
22+
public EstimateABTestResponse setDurationDays(Long durationDays) {
23+
this.durationDays = durationDays;
24+
return this;
25+
}
26+
27+
/**
28+
* Estimated number of days needed to reach the sample sizes required for detecting the configured
29+
* effect. This value is based on historical traffic.
30+
*/
31+
@javax.annotation.Nullable
32+
public Long getDurationDays() {
33+
return durationDays;
34+
}
35+
36+
public EstimateABTestResponse setControlSampleSize(Long controlSampleSize) {
37+
this.controlSampleSize = controlSampleSize;
38+
return this;
39+
}
40+
41+
/**
42+
* Number of tracked searches needed to be able to detect the configured effect for the control
43+
* variant.
44+
*/
45+
@javax.annotation.Nullable
46+
public Long getControlSampleSize() {
47+
return controlSampleSize;
48+
}
49+
50+
public EstimateABTestResponse setExperimentSampleSize(Long experimentSampleSize) {
51+
this.experimentSampleSize = experimentSampleSize;
52+
return this;
53+
}
54+
55+
/**
56+
* Number of tracked searches needed to be able to detect the configured effect for the experiment
57+
* variant.
58+
*/
59+
@javax.annotation.Nullable
60+
public Long getExperimentSampleSize() {
61+
return experimentSampleSize;
62+
}
63+
64+
@Override
65+
public boolean equals(Object o) {
66+
if (this == o) {
67+
return true;
68+
}
69+
if (o == null || getClass() != o.getClass()) {
70+
return false;
71+
}
72+
EstimateABTestResponse estimateABTestResponse = (EstimateABTestResponse) o;
73+
return (
74+
Objects.equals(this.durationDays, estimateABTestResponse.durationDays) &&
75+
Objects.equals(this.controlSampleSize, estimateABTestResponse.controlSampleSize) &&
76+
Objects.equals(this.experimentSampleSize, estimateABTestResponse.experimentSampleSize)
77+
);
78+
}
79+
80+
@Override
81+
public int hashCode() {
82+
return Objects.hash(durationDays, controlSampleSize, experimentSampleSize);
83+
}
84+
85+
@Override
86+
public String toString() {
87+
StringBuilder sb = new StringBuilder();
88+
sb.append("class EstimateABTestResponse {\n");
89+
sb.append(" durationDays: ").append(toIndentedString(durationDays)).append("\n");
90+
sb.append(" controlSampleSize: ").append(toIndentedString(controlSampleSize)).append("\n");
91+
sb.append(" experimentSampleSize: ").append(toIndentedString(experimentSampleSize)).append("\n");
92+
sb.append("}");
93+
return sb.toString();
94+
}
95+
96+
/**
97+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
98+
*/
99+
private String toIndentedString(Object o) {
100+
if (o == null) {
101+
return "null";
102+
}
103+
return o.toString().replace("\n", "\n ");
104+
}
105+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.abtesting;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.Objects;
9+
10+
/**
11+
* A/B test configuration for estimating the sample size and duration using minimum detectable
12+
* effect.
13+
*/
14+
public class EstimateConfiguration {
15+
16+
@JsonProperty("outliers")
17+
private Outliers outliers;
18+
19+
@JsonProperty("emptySearch")
20+
private EmptySearch emptySearch;
21+
22+
@JsonProperty("minimumDetectableEffect")
23+
private MinimumDetectableEffect minimumDetectableEffect;
24+
25+
public EstimateConfiguration setOutliers(Outliers outliers) {
26+
this.outliers = outliers;
27+
return this;
28+
}
29+
30+
/** Get outliers */
31+
@javax.annotation.Nullable
32+
public Outliers getOutliers() {
33+
return outliers;
34+
}
35+
36+
public EstimateConfiguration setEmptySearch(EmptySearch emptySearch) {
37+
this.emptySearch = emptySearch;
38+
return this;
39+
}
40+
41+
/** Get emptySearch */
42+
@javax.annotation.Nullable
43+
public EmptySearch getEmptySearch() {
44+
return emptySearch;
45+
}
46+
47+
public EstimateConfiguration setMinimumDetectableEffect(MinimumDetectableEffect minimumDetectableEffect) {
48+
this.minimumDetectableEffect = minimumDetectableEffect;
49+
return this;
50+
}
51+
52+
/** Get minimumDetectableEffect */
53+
@javax.annotation.Nonnull
54+
public MinimumDetectableEffect getMinimumDetectableEffect() {
55+
return minimumDetectableEffect;
56+
}
57+
58+
@Override
59+
public boolean equals(Object o) {
60+
if (this == o) {
61+
return true;
62+
}
63+
if (o == null || getClass() != o.getClass()) {
64+
return false;
65+
}
66+
EstimateConfiguration estimateConfiguration = (EstimateConfiguration) o;
67+
return (
68+
Objects.equals(this.outliers, estimateConfiguration.outliers) &&
69+
Objects.equals(this.emptySearch, estimateConfiguration.emptySearch) &&
70+
Objects.equals(this.minimumDetectableEffect, estimateConfiguration.minimumDetectableEffect)
71+
);
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
return Objects.hash(outliers, emptySearch, minimumDetectableEffect);
77+
}
78+
79+
@Override
80+
public String toString() {
81+
StringBuilder sb = new StringBuilder();
82+
sb.append("class EstimateConfiguration {\n");
83+
sb.append(" outliers: ").append(toIndentedString(outliers)).append("\n");
84+
sb.append(" emptySearch: ").append(toIndentedString(emptySearch)).append("\n");
85+
sb.append(" minimumDetectableEffect: ").append(toIndentedString(minimumDetectableEffect)).append("\n");
86+
sb.append("}");
87+
return sb.toString();
88+
}
89+
90+
/**
91+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
92+
*/
93+
private String toIndentedString(Object o) {
94+
if (o == null) {
95+
return "null";
96+
}
97+
return o.toString().replace("\n", "\n ");
98+
}
99+
}

0 commit comments

Comments
 (0)