Skip to content

Commit ec90bd4

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 <[email protected]> Co-authored-by: Christopher Hawke <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 669fbab commit ec90bd4

File tree

7 files changed

+151
-17
lines changed

7 files changed

+151
-17
lines changed

src/main/scala/algoliasearch/abtesting/Effect.scala renamed to src/main/scala/algoliasearch/abtesting/EffectMetric.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,38 @@ package algoliasearch.abtesting
2626

2727
import org.json4s._
2828

29-
sealed trait Effect
29+
sealed trait EffectMetric
3030

3131
/** Metric for which you want to detect the smallest relative difference.
3232
*/
33-
object Effect {
34-
case object AddToCartRate extends Effect {
33+
object EffectMetric {
34+
case object AddToCartRate extends EffectMetric {
3535
override def toString = "addToCartRate"
3636
}
37-
case object ClickThroughRate extends Effect {
37+
case object ClickThroughRate extends EffectMetric {
3838
override def toString = "clickThroughRate"
3939
}
40-
case object ConversionRate extends Effect {
40+
case object ConversionRate extends EffectMetric {
4141
override def toString = "conversionRate"
4242
}
43-
case object PurchaseRate extends Effect {
43+
case object PurchaseRate extends EffectMetric {
4444
override def toString = "purchaseRate"
4545
}
46-
val values: Seq[Effect] = Seq(AddToCartRate, ClickThroughRate, ConversionRate, PurchaseRate)
46+
val values: Seq[EffectMetric] = Seq(AddToCartRate, ClickThroughRate, ConversionRate, PurchaseRate)
4747

48-
def withName(name: String): Effect = Effect.values
48+
def withName(name: String): EffectMetric = EffectMetric.values
4949
.find(_.toString == name)
50-
.getOrElse(throw new MappingException(s"Unknown Effect value: $name"))
50+
.getOrElse(throw new MappingException(s"Unknown EffectMetric value: $name"))
5151
}
5252

53-
class EffectSerializer
54-
extends CustomSerializer[Effect](_ =>
53+
class EffectMetricSerializer
54+
extends CustomSerializer[EffectMetric](_ =>
5555
(
5656
{
57-
case JString(value) => Effect.withName(value)
57+
case JString(value) => EffectMetric.withName(value)
5858
case JNull => null
5959
},
60-
{ case value: Effect =>
60+
{ case value: EffectMetric =>
6161
JString(value.toString)
6262
}
6363
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/** A/B Testing API The Algolia A/B Testing API lets you manage your Algolia A/B tests to optimize your search
2+
* experience. ## Base URLs The base URLs for requests to the A/B testing API are: - `https://analytics.us.algolia.com`
3+
* \- `https://analytics.de.algolia.com` - `https://analytics.algolia.com` (routes requests to the closest of the above
4+
* servers, based on your geographical location) Use the URL that matches your [analytics
5+
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
6+
* Availability and authentication Access to the A/B testing API is available as part of the [Premium or Elevate
7+
* plans](https://www.algolia.com/pricing). To authenticate your API requests, add these headers: -
8+
* `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the necessary
9+
* permissions to make the request. The required access control list (ACL) to make a request is listed in each
10+
* endpoint's reference. You can find your application ID and API key in the [Algolia
11+
* dashboard](https://dashboard.algolia.com/account). ## Rate limits You can make up to **100 requests per minute per
12+
* app** to the A/B testing API. The response includes headers with information about the limits. ## Parameters Query
13+
* parameters must be [URL-encoded](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding). Non-ASCII
14+
* characters must be UTF-8 encoded. Plus characters (`+`) are interpreted as spaces. ## Response status and errors The
15+
* A/B testing API returns JSON responses. Since JSON doesn't guarantee any specific ordering, don't rely on the order
16+
* of attributes in the API response. Successful responses return a `2xx` status. Client errors return a `4xx` status.
17+
* Server errors are indicated by a `5xx` status. Error responses have a `message` property with more information. ##
18+
* Version The current version of the A/B Testing API is version 2, as indicated by the `/2/` in each endpoint's URL.
19+
*
20+
* The version of the OpenAPI document: 2.0.0
21+
*
22+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
23+
* https://openapi-generator.tech Do not edit the class manually.
24+
*/
25+
package algoliasearch.abtesting
26+
27+
/** EstimateABTestRequest
28+
*
29+
* @param variants
30+
* A/B test variants.
31+
*/
32+
case class EstimateABTestRequest(
33+
configuration: EstimateConfiguration,
34+
variants: Seq[AddABTestsVariant]
35+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/** A/B Testing API The Algolia A/B Testing API lets you manage your Algolia A/B tests to optimize your search
2+
* experience. ## Base URLs The base URLs for requests to the A/B testing API are: - `https://analytics.us.algolia.com`
3+
* \- `https://analytics.de.algolia.com` - `https://analytics.algolia.com` (routes requests to the closest of the above
4+
* servers, based on your geographical location) Use the URL that matches your [analytics
5+
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
6+
* Availability and authentication Access to the A/B testing API is available as part of the [Premium or Elevate
7+
* plans](https://www.algolia.com/pricing). To authenticate your API requests, add these headers: -
8+
* `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the necessary
9+
* permissions to make the request. The required access control list (ACL) to make a request is listed in each
10+
* endpoint's reference. You can find your application ID and API key in the [Algolia
11+
* dashboard](https://dashboard.algolia.com/account). ## Rate limits You can make up to **100 requests per minute per
12+
* app** to the A/B testing API. The response includes headers with information about the limits. ## Parameters Query
13+
* parameters must be [URL-encoded](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding). Non-ASCII
14+
* characters must be UTF-8 encoded. Plus characters (`+`) are interpreted as spaces. ## Response status and errors The
15+
* A/B testing API returns JSON responses. Since JSON doesn't guarantee any specific ordering, don't rely on the order
16+
* of attributes in the API response. Successful responses return a `2xx` status. Client errors return a `4xx` status.
17+
* Server errors are indicated by a `5xx` status. Error responses have a `message` property with more information. ##
18+
* Version The current version of the A/B Testing API is version 2, as indicated by the `/2/` in each endpoint's URL.
19+
*
20+
* The version of the OpenAPI document: 2.0.0
21+
*
22+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
23+
* https://openapi-generator.tech Do not edit the class manually.
24+
*/
25+
package algoliasearch.abtesting
26+
27+
/** EstimateABTestResponse
28+
*
29+
* @param durationDays
30+
* Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value
31+
* is based on historical traffic.
32+
* @param controlSampleSize
33+
* Number of tracked searches needed to be able to detect the configured effect for the control variant.
34+
* @param experimentSampleSize
35+
* Number of tracked searches needed to be able to detect the configured effect for the experiment variant.
36+
*/
37+
case class EstimateABTestResponse(
38+
durationDays: Option[Long] = scala.None,
39+
controlSampleSize: Option[Long] = scala.None,
40+
experimentSampleSize: Option[Long] = scala.None
41+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/** A/B Testing API The Algolia A/B Testing API lets you manage your Algolia A/B tests to optimize your search
2+
* experience. ## Base URLs The base URLs for requests to the A/B testing API are: - `https://analytics.us.algolia.com`
3+
* \- `https://analytics.de.algolia.com` - `https://analytics.algolia.com` (routes requests to the closest of the above
4+
* servers, based on your geographical location) Use the URL that matches your [analytics
5+
* region](https://dashboard.algolia.com/account/infrastructure/analytics). **All requests must use HTTPS.** ##
6+
* Availability and authentication Access to the A/B testing API is available as part of the [Premium or Elevate
7+
* plans](https://www.algolia.com/pricing). To authenticate your API requests, add these headers: -
8+
* `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the necessary
9+
* permissions to make the request. The required access control list (ACL) to make a request is listed in each
10+
* endpoint's reference. You can find your application ID and API key in the [Algolia
11+
* dashboard](https://dashboard.algolia.com/account). ## Rate limits You can make up to **100 requests per minute per
12+
* app** to the A/B testing API. The response includes headers with information about the limits. ## Parameters Query
13+
* parameters must be [URL-encoded](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding). Non-ASCII
14+
* characters must be UTF-8 encoded. Plus characters (`+`) are interpreted as spaces. ## Response status and errors The
15+
* A/B testing API returns JSON responses. Since JSON doesn't guarantee any specific ordering, don't rely on the order
16+
* of attributes in the API response. Successful responses return a `2xx` status. Client errors return a `4xx` status.
17+
* Server errors are indicated by a `5xx` status. Error responses have a `message` property with more information. ##
18+
* Version The current version of the A/B Testing API is version 2, as indicated by the `/2/` in each endpoint's URL.
19+
*
20+
* The version of the OpenAPI document: 2.0.0
21+
*
22+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
23+
* https://openapi-generator.tech Do not edit the class manually.
24+
*/
25+
package algoliasearch.abtesting
26+
27+
/** A/B test configuration for estimating the sample size and duration using minimum detectable effect.
28+
*/
29+
case class EstimateConfiguration(
30+
outliers: Option[Outliers] = scala.None,
31+
emptySearch: Option[EmptySearch] = scala.None,
32+
minimumDetectableEffect: MinimumDetectableEffect
33+
)

src/main/scala/algoliasearch/abtesting/JsonSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.json4s._
2828

2929
object JsonSupport {
3030
private def enumSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+
31-
new EffectSerializer() :+
31+
new EffectMetricSerializer() :+
3232
new StatusSerializer()
3333

3434
private def oneOfsSerializers: Seq[Serializer[_]] = Seq[Serializer[_]]() :+

src/main/scala/algoliasearch/abtesting/MinimumDetectableEffect.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
package algoliasearch.abtesting
2626

27-
import algoliasearch.abtesting.Effect._
27+
import algoliasearch.abtesting.EffectMetric._
2828

2929
/** Configuration for the smallest difference between test variants you want to detect.
3030
*
@@ -33,6 +33,6 @@ import algoliasearch.abtesting.Effect._
3333
* variants, set this value to 0.1.
3434
*/
3535
case class MinimumDetectableEffect(
36-
size: Option[Double] = scala.None,
37-
effect: Option[Effect] = scala.None
36+
size: Double,
37+
metric: EffectMetric
3838
)

src/main/scala/algoliasearch/api/AbtestingClient.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import algoliasearch.abtesting.ABTest
77
import algoliasearch.abtesting.ABTestResponse
88
import algoliasearch.abtesting.AddABTestsRequest
99
import algoliasearch.abtesting.ErrorBase
10+
import algoliasearch.abtesting.EstimateABTestRequest
11+
import algoliasearch.abtesting.EstimateABTestResponse
1012
import algoliasearch.abtesting.ListABTestsResponse
1113
import algoliasearch.abtesting.ScheduleABTestResponse
1214
import algoliasearch.abtesting.ScheduleABTestsRequest
@@ -209,6 +211,29 @@ class AbtestingClient(
209211
execute[ABTestResponse](request, requestOptions)
210212
}
211213

214+
/** Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of
215+
* an A/B test based on historical traffic.
216+
*
217+
* Required API Key ACLs:
218+
* - analytics
219+
*/
220+
def estimateABTest(estimateABTestRequest: EstimateABTestRequest, requestOptions: Option[RequestOptions] = None)(
221+
implicit ec: ExecutionContext
222+
): Future[EstimateABTestResponse] = Future {
223+
requireNotNull(
224+
estimateABTestRequest,
225+
"Parameter `estimateABTestRequest` is required when calling `estimateABTest`."
226+
)
227+
228+
val request = HttpRequest
229+
.builder()
230+
.withMethod("POST")
231+
.withPath(s"/2/abtests/estimate")
232+
.withBody(estimateABTestRequest)
233+
.build()
234+
execute[EstimateABTestResponse](request, requestOptions)
235+
}
236+
212237
/** Retrieves the details for an A/B test by its ID.
213238
*
214239
* Required API Key ACLs:

0 commit comments

Comments
 (0)