Skip to content

Commit

Permalink
feat(specs): add estimate path and responses [skip-bc] (generated)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
3 people committed Nov 7, 2024
1 parent 0738753 commit b61b3d3
Show file tree
Hide file tree
Showing 6 changed files with 404 additions and 10 deletions.
50 changes: 50 additions & 0 deletions algoliasearch/Clients/AbtestingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,36 @@ public interface IAbtestingClient
/// <returns>ABTestResponse</returns>
ABTestResponse DeleteABTest(int id, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// 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.
/// </summary>
///
/// Required API Key ACLs:
/// - analytics
/// <param name="estimateABTestRequest"></param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
/// <returns>Task of EstimateABTestResponse</returns>
Task<EstimateABTestResponse> EstimateABTestAsync(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// 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)
/// </summary>
///
/// Required API Key ACLs:
/// - analytics
/// <param name="estimateABTestRequest"></param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
/// <returns>EstimateABTestResponse</returns>
EstimateABTestResponse EstimateABTest(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieves the details for an A/B test by its ID.
/// </summary>
Expand Down Expand Up @@ -513,6 +543,26 @@ public ABTestResponse DeleteABTest(int id, RequestOptions options = null, Cancel
AsyncHelper.RunSync(() => DeleteABTestAsync(id, options, cancellationToken));


/// <inheritdoc />
public async Task<EstimateABTestResponse> EstimateABTestAsync(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default)
{

if (estimateABTestRequest == null)
throw new ArgumentException("Parameter `estimateABTestRequest` is required when calling `EstimateABTest`.");

var requestOptions = new InternalRequestOptions(options);


requestOptions.Data = estimateABTestRequest;
return await _transport.ExecuteRequestAsync<EstimateABTestResponse>(new HttpMethod("POST"), "/2/abtests/estimate", requestOptions, cancellationToken).ConfigureAwait(false);
}


/// <inheritdoc />
public EstimateABTestResponse EstimateABTest(EstimateABTestRequest estimateABTestRequest, RequestOptions options = null, CancellationToken cancellationToken = default) =>
AsyncHelper.RunSync(() => EstimateABTestAsync(estimateABTestRequest, options, cancellationToken));


/// <inheritdoc />
public async Task<ABTest> GetABTestAsync(int id, RequestOptions options = null, CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Algolia.Search.Models.Abtesting;
/// Metric for which you want to detect the smallest relative difference.
/// </summary>
/// <value>Metric for which you want to detect the smallest relative difference.</value>
[JsonConverter(typeof(Serializer.JsonStringEnumConverter<Effect>))]
public enum Effect
[JsonConverter(typeof(Serializer.JsonStringEnumConverter<EffectMetric>))]
public enum EffectMetric
{
/// <summary>
/// Enum AddToCartRate for value: addToCartRate
Expand Down
110 changes: 110 additions & 0 deletions algoliasearch/Models/Abtesting/EstimateABTestRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
//
// 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.
//
using System;
using System.Text;
using System.Linq;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using Algolia.Search.Serializer;
using System.Text.Json;

namespace Algolia.Search.Models.Abtesting;

/// <summary>
/// EstimateABTestRequest
/// </summary>
public partial class EstimateABTestRequest
{
/// <summary>
/// Initializes a new instance of the EstimateABTestRequest class.
/// </summary>
[JsonConstructor]
public EstimateABTestRequest() { }
/// <summary>
/// Initializes a new instance of the EstimateABTestRequest class.
/// </summary>
/// <param name="configuration">configuration (required).</param>
/// <param name="variants">A/B test variants. (required).</param>
public EstimateABTestRequest(EstimateConfiguration configuration, List<AddABTestsVariant> variants)
{
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
Variants = variants ?? throw new ArgumentNullException(nameof(variants));
}

/// <summary>
/// Gets or Sets Configuration
/// </summary>
[JsonPropertyName("configuration")]
public EstimateConfiguration Configuration { get; set; }

/// <summary>
/// A/B test variants.
/// </summary>
/// <value>A/B test variants.</value>
[JsonPropertyName("variants")]
public List<AddABTestsVariant> Variants { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class EstimateABTestRequest {\n");
sb.Append(" Configuration: ").Append(Configuration).Append("\n");
sb.Append(" Variants: ").Append(Variants).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return JsonSerializer.Serialize(this, JsonConfig.Options);
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is not EstimateABTestRequest input)
{
return false;
}

return
(Configuration == input.Configuration || (Configuration != null && Configuration.Equals(input.Configuration))) &&
(Variants == input.Variants || Variants != null && input.Variants != null && Variants.SequenceEqual(input.Variants));
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (Configuration != null)
{
hashCode = (hashCode * 59) + Configuration.GetHashCode();
}
if (Variants != null)
{
hashCode = (hashCode * 59) + Variants.GetHashCode();
}
return hashCode;
}
}

}

106 changes: 106 additions & 0 deletions algoliasearch/Models/Abtesting/EstimateABTestResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// 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.
//
using System;
using System.Text;
using System.Linq;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using Algolia.Search.Serializer;
using System.Text.Json;

namespace Algolia.Search.Models.Abtesting;

/// <summary>
/// EstimateABTestResponse
/// </summary>
public partial class EstimateABTestResponse
{
/// <summary>
/// Initializes a new instance of the EstimateABTestResponse class.
/// </summary>
public EstimateABTestResponse()
{
}

/// <summary>
/// Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value is based on historical traffic.
/// </summary>
/// <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>
[JsonPropertyName("durationDays")]
public long? DurationDays { get; set; }

/// <summary>
/// Number of tracked searches needed to be able to detect the configured effect for the control variant.
/// </summary>
/// <value>Number of tracked searches needed to be able to detect the configured effect for the control variant.</value>
[JsonPropertyName("controlSampleSize")]
public long? ControlSampleSize { get; set; }

/// <summary>
/// Number of tracked searches needed to be able to detect the configured effect for the experiment variant.
/// </summary>
/// <value>Number of tracked searches needed to be able to detect the configured effect for the experiment variant.</value>
[JsonPropertyName("experimentSampleSize")]
public long? ExperimentSampleSize { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class EstimateABTestResponse {\n");
sb.Append(" DurationDays: ").Append(DurationDays).Append("\n");
sb.Append(" ControlSampleSize: ").Append(ControlSampleSize).Append("\n");
sb.Append(" ExperimentSampleSize: ").Append(ExperimentSampleSize).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return JsonSerializer.Serialize(this, JsonConfig.Options);
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is not EstimateABTestResponse input)
{
return false;
}

return
(DurationDays == input.DurationDays || DurationDays.Equals(input.DurationDays)) &&
(ControlSampleSize == input.ControlSampleSize || ControlSampleSize.Equals(input.ControlSampleSize)) &&
(ExperimentSampleSize == input.ExperimentSampleSize || ExperimentSampleSize.Equals(input.ExperimentSampleSize));
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
hashCode = (hashCode * 59) + DurationDays.GetHashCode();
hashCode = (hashCode * 59) + ControlSampleSize.GetHashCode();
hashCode = (hashCode * 59) + ExperimentSampleSize.GetHashCode();
return hashCode;
}
}

}

Loading

0 comments on commit b61b3d3

Please sign in to comment.