Skip to content

Commit b61b3d3

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 0738753 commit b61b3d3

File tree

6 files changed

+404
-10
lines changed

6 files changed

+404
-10
lines changed

algoliasearch/Clients/AbtestingClient.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,36 @@ public interface IAbtestingClient
189189
/// <returns>ABTestResponse</returns>
190190
ABTestResponse DeleteABTest(int id, RequestOptions options = null, CancellationToken cancellationToken = default);
191191

192+
/// <summary>
193+
/// Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic.
194+
/// </summary>
195+
///
196+
/// Required API Key ACLs:
197+
/// - analytics
198+
/// <param name="estimateABTestRequest"></param>
199+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
200+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
201+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
202+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
203+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
204+
/// <returns>Task of EstimateABTestResponse</returns>
205+
Task<EstimateABTestResponse> EstimateABTestAsync(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default);
206+
207+
/// <summary>
208+
/// Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic. (Synchronous version)
209+
/// </summary>
210+
///
211+
/// Required API Key ACLs:
212+
/// - analytics
213+
/// <param name="estimateABTestRequest"></param>
214+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
215+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
216+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
217+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
218+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
219+
/// <returns>EstimateABTestResponse</returns>
220+
EstimateABTestResponse EstimateABTest(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default);
221+
192222
/// <summary>
193223
/// Retrieves the details for an A/B test by its ID.
194224
/// </summary>
@@ -513,6 +543,26 @@ public ABTestResponse DeleteABTest(int id, RequestOptions options = null, Cancel
513543
AsyncHelper.RunSync(() => DeleteABTestAsync(id, options, cancellationToken));
514544

515545

546+
/// <inheritdoc />
547+
public async Task<EstimateABTestResponse> EstimateABTestAsync(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default)
548+
{
549+
550+
if (estimateABTestRequest == null)
551+
throw new ArgumentException("Parameter `estimateABTestRequest` is required when calling `EstimateABTest`.");
552+
553+
var requestOptions = new InternalRequestOptions(options);
554+
555+
556+
requestOptions.Data = estimateABTestRequest;
557+
return await _transport.ExecuteRequestAsync<EstimateABTestResponse>(new HttpMethod("POST"), "/2/abtests/estimate", requestOptions, cancellationToken).ConfigureAwait(false);
558+
}
559+
560+
561+
/// <inheritdoc />
562+
public EstimateABTestResponse EstimateABTest(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default) =>
563+
AsyncHelper.RunSync(() => EstimateABTestAsync(estimateABTestRequest, options, cancellationToken));
564+
565+
516566
/// <inheritdoc />
517567
public async Task<ABTest> GetABTestAsync(int id, RequestOptions options = null, CancellationToken cancellationToken = default)
518568
{

algoliasearch/Models/Abtesting/Effect.cs renamed to algoliasearch/Models/Abtesting/EffectMetric.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Algolia.Search.Models.Abtesting;
1515
/// Metric for which you want to detect the smallest relative difference.
1616
/// </summary>
1717
/// <value>Metric for which you want to detect the smallest relative difference.</value>
18-
[JsonConverter(typeof(Serializer.JsonStringEnumConverter<Effect>))]
19-
public enum Effect
18+
[JsonConverter(typeof(Serializer.JsonStringEnumConverter<EffectMetric>))]
19+
public enum EffectMetric
2020
{
2121
/// <summary>
2222
/// Enum AddToCartRate for value: addToCartRate
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Abtesting;
13+
14+
/// <summary>
15+
/// EstimateABTestRequest
16+
/// </summary>
17+
public partial class EstimateABTestRequest
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the EstimateABTestRequest class.
21+
/// </summary>
22+
[JsonConstructor]
23+
public EstimateABTestRequest() { }
24+
/// <summary>
25+
/// Initializes a new instance of the EstimateABTestRequest class.
26+
/// </summary>
27+
/// <param name="configuration">configuration (required).</param>
28+
/// <param name="variants">A/B test variants. (required).</param>
29+
public EstimateABTestRequest(EstimateConfiguration configuration, List<AddABTestsVariant> variants)
30+
{
31+
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
32+
Variants = variants ?? throw new ArgumentNullException(nameof(variants));
33+
}
34+
35+
/// <summary>
36+
/// Gets or Sets Configuration
37+
/// </summary>
38+
[JsonPropertyName("configuration")]
39+
public EstimateConfiguration Configuration { get; set; }
40+
41+
/// <summary>
42+
/// A/B test variants.
43+
/// </summary>
44+
/// <value>A/B test variants.</value>
45+
[JsonPropertyName("variants")]
46+
public List<AddABTestsVariant> Variants { get; set; }
47+
48+
/// <summary>
49+
/// Returns the string presentation of the object
50+
/// </summary>
51+
/// <returns>String presentation of the object</returns>
52+
public override string ToString()
53+
{
54+
StringBuilder sb = new StringBuilder();
55+
sb.Append("class EstimateABTestRequest {\n");
56+
sb.Append(" Configuration: ").Append(Configuration).Append("\n");
57+
sb.Append(" Variants: ").Append(Variants).Append("\n");
58+
sb.Append("}\n");
59+
return sb.ToString();
60+
}
61+
62+
/// <summary>
63+
/// Returns the JSON string presentation of the object
64+
/// </summary>
65+
/// <returns>JSON string presentation of the object</returns>
66+
public virtual string ToJson()
67+
{
68+
return JsonSerializer.Serialize(this, JsonConfig.Options);
69+
}
70+
71+
/// <summary>
72+
/// Returns true if objects are equal
73+
/// </summary>
74+
/// <param name="obj">Object to be compared</param>
75+
/// <returns>Boolean</returns>
76+
public override bool Equals(object obj)
77+
{
78+
if (obj is not EstimateABTestRequest input)
79+
{
80+
return false;
81+
}
82+
83+
return
84+
(Configuration == input.Configuration || (Configuration != null && Configuration.Equals(input.Configuration))) &&
85+
(Variants == input.Variants || Variants != null && input.Variants != null && Variants.SequenceEqual(input.Variants));
86+
}
87+
88+
/// <summary>
89+
/// Gets the hash code
90+
/// </summary>
91+
/// <returns>Hash code</returns>
92+
public override int GetHashCode()
93+
{
94+
unchecked // Overflow is fine, just wrap
95+
{
96+
int hashCode = 41;
97+
if (Configuration != null)
98+
{
99+
hashCode = (hashCode * 59) + Configuration.GetHashCode();
100+
}
101+
if (Variants != null)
102+
{
103+
hashCode = (hashCode * 59) + Variants.GetHashCode();
104+
}
105+
return hashCode;
106+
}
107+
}
108+
109+
}
110+
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Abtesting;
13+
14+
/// <summary>
15+
/// EstimateABTestResponse
16+
/// </summary>
17+
public partial class EstimateABTestResponse
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the EstimateABTestResponse class.
21+
/// </summary>
22+
public EstimateABTestResponse()
23+
{
24+
}
25+
26+
/// <summary>
27+
/// Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value is based on historical traffic.
28+
/// </summary>
29+
/// <value>Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value is based on historical traffic.</value>
30+
[JsonPropertyName("durationDays")]
31+
public long? DurationDays { get; set; }
32+
33+
/// <summary>
34+
/// Number of tracked searches needed to be able to detect the configured effect for the control variant.
35+
/// </summary>
36+
/// <value>Number of tracked searches needed to be able to detect the configured effect for the control variant.</value>
37+
[JsonPropertyName("controlSampleSize")]
38+
public long? ControlSampleSize { get; set; }
39+
40+
/// <summary>
41+
/// Number of tracked searches needed to be able to detect the configured effect for the experiment variant.
42+
/// </summary>
43+
/// <value>Number of tracked searches needed to be able to detect the configured effect for the experiment variant.</value>
44+
[JsonPropertyName("experimentSampleSize")]
45+
public long? ExperimentSampleSize { get; set; }
46+
47+
/// <summary>
48+
/// Returns the string presentation of the object
49+
/// </summary>
50+
/// <returns>String presentation of the object</returns>
51+
public override string ToString()
52+
{
53+
StringBuilder sb = new StringBuilder();
54+
sb.Append("class EstimateABTestResponse {\n");
55+
sb.Append(" DurationDays: ").Append(DurationDays).Append("\n");
56+
sb.Append(" ControlSampleSize: ").Append(ControlSampleSize).Append("\n");
57+
sb.Append(" ExperimentSampleSize: ").Append(ExperimentSampleSize).Append("\n");
58+
sb.Append("}\n");
59+
return sb.ToString();
60+
}
61+
62+
/// <summary>
63+
/// Returns the JSON string presentation of the object
64+
/// </summary>
65+
/// <returns>JSON string presentation of the object</returns>
66+
public virtual string ToJson()
67+
{
68+
return JsonSerializer.Serialize(this, JsonConfig.Options);
69+
}
70+
71+
/// <summary>
72+
/// Returns true if objects are equal
73+
/// </summary>
74+
/// <param name="obj">Object to be compared</param>
75+
/// <returns>Boolean</returns>
76+
public override bool Equals(object obj)
77+
{
78+
if (obj is not EstimateABTestResponse input)
79+
{
80+
return false;
81+
}
82+
83+
return
84+
(DurationDays == input.DurationDays || DurationDays.Equals(input.DurationDays)) &&
85+
(ControlSampleSize == input.ControlSampleSize || ControlSampleSize.Equals(input.ControlSampleSize)) &&
86+
(ExperimentSampleSize == input.ExperimentSampleSize || ExperimentSampleSize.Equals(input.ExperimentSampleSize));
87+
}
88+
89+
/// <summary>
90+
/// Gets the hash code
91+
/// </summary>
92+
/// <returns>Hash code</returns>
93+
public override int GetHashCode()
94+
{
95+
unchecked // Overflow is fine, just wrap
96+
{
97+
int hashCode = 41;
98+
hashCode = (hashCode * 59) + DurationDays.GetHashCode();
99+
hashCode = (hashCode * 59) + ControlSampleSize.GetHashCode();
100+
hashCode = (hashCode * 59) + ExperimentSampleSize.GetHashCode();
101+
return hashCode;
102+
}
103+
}
104+
105+
}
106+

0 commit comments

Comments
 (0)