From b61e6a5f0caa547c98a0b97aaefe0a3ff9527e76 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Tue, 20 Aug 2024 10:00:48 +0000 Subject: [PATCH] feat(specs): add /schedule endpoint (generated) https://github.com/algolia/api-clients-automation/pull/3350 Co-authored-by: algolia-bot Co-authored-by: Fernando Beck Co-authored-by: Pierre Millot --- algoliasearch/Clients/AbtestingClient.cs | 68 +++++++++ .../Abtesting/ScheduleABTestResponse.cs | 93 ++++++++++++ .../Abtesting/ScheduleABTestsRequest.cs | 141 ++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 algoliasearch/Models/Abtesting/ScheduleABTestResponse.cs create mode 100644 algoliasearch/Models/Abtesting/ScheduleABTestsRequest.cs diff --git a/algoliasearch/Clients/AbtestingClient.cs b/algoliasearch/Clients/AbtestingClient.cs index 3bfa8f027..59e3e6df0 100644 --- a/algoliasearch/Clients/AbtestingClient.cs +++ b/algoliasearch/Clients/AbtestingClient.cs @@ -231,6 +231,30 @@ public interface IAbtestingClient /// ListABTestsResponse ListABTestsResponse ListABTests(int? offset = default, int? limit = default, string indexPrefix = default, string indexSuffix = default, RequestOptions options = null, CancellationToken cancellationToken = default); + /// + /// Schedule an A/B test to be started at a later time. + /// + /// + /// Add extra http header or query parameters to Algolia. + /// Cancellation Token to cancel the request. + /// Thrown when arguments are not correct + /// Thrown when the API call was rejected by Algolia + /// Thrown when the client failed to call the endpoint + /// Task of ScheduleABTestResponse + Task ScheduleABTestAsync(ScheduleABTestsRequest scheduleABTestsRequest, RequestOptions options = null, CancellationToken cancellationToken = default); + + /// + /// Schedule an A/B test to be started at a later time. (Synchronous version) + /// + /// + /// Add extra http header or query parameters to Algolia. + /// Cancellation Token to cancel the request. + /// Thrown when arguments are not correct + /// Thrown when the API call was rejected by Algolia + /// Thrown when the client failed to call the endpoint + /// ScheduleABTestResponse + ScheduleABTestResponse ScheduleABTest(ScheduleABTestsRequest scheduleABTestsRequest, RequestOptions options = null, CancellationToken cancellationToken = default); + /// /// Stops an A/B test by its ID. You can't restart stopped A/B tests. /// @@ -664,6 +688,50 @@ public ListABTestsResponse ListABTests(int? offset = default, int? limit = defau AsyncHelper.RunSync(() => ListABTestsAsync(offset, limit, indexPrefix, indexSuffix, options, cancellationToken)); + /// + /// Schedule an A/B test to be started at a later time. + /// + /// + /// Required API Key ACLs: + /// - editSettings + /// + /// Add extra http header or query parameters to Algolia. + /// Cancellation Token to cancel the request. + /// Thrown when arguments are not correct + /// Thrown when the API call was rejected by Algolia + /// Thrown when the client failed to call the endpoint + /// Task of ScheduleABTestResponse + public async Task ScheduleABTestAsync(ScheduleABTestsRequest scheduleABTestsRequest, RequestOptions options = null, CancellationToken cancellationToken = default) + { + + if (scheduleABTestsRequest == null) + throw new ArgumentException("Parameter `scheduleABTestsRequest` is required when calling `ScheduleABTest`."); + + var requestOptions = new InternalRequestOptions(options); + + + requestOptions.Data = scheduleABTestsRequest; + return await _transport.ExecuteRequestAsync(new HttpMethod("POST"), "/2/abtests/schedule", requestOptions, cancellationToken).ConfigureAwait(false); + } + + + /// + /// Schedule an A/B test to be started at a later time. (Synchronous version) + /// + /// + /// Required API Key ACLs: + /// - editSettings + /// + /// Add extra http header or query parameters to Algolia. + /// Cancellation Token to cancel the request. + /// Thrown when arguments are not correct + /// Thrown when the API call was rejected by Algolia + /// Thrown when the client failed to call the endpoint + /// ScheduleABTestResponse + public ScheduleABTestResponse ScheduleABTest(ScheduleABTestsRequest scheduleABTestsRequest, RequestOptions options = null, CancellationToken cancellationToken = default) => + AsyncHelper.RunSync(() => ScheduleABTestAsync(scheduleABTestsRequest, options, cancellationToken)); + + /// /// Stops an A/B test by its ID. You can't restart stopped A/B tests. /// diff --git a/algoliasearch/Models/Abtesting/ScheduleABTestResponse.cs b/algoliasearch/Models/Abtesting/ScheduleABTestResponse.cs new file mode 100644 index 000000000..04ab960e1 --- /dev/null +++ b/algoliasearch/Models/Abtesting/ScheduleABTestResponse.cs @@ -0,0 +1,93 @@ +// +// 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; + +/// +/// ScheduleABTestResponse +/// +public partial class ScheduleABTestResponse +{ + /// + /// Initializes a new instance of the ScheduleABTestResponse class. + /// + [JsonConstructor] + public ScheduleABTestResponse() { } + /// + /// Initializes a new instance of the ScheduleABTestResponse class. + /// + /// Unique scheduled A/B test identifier. (required). + public ScheduleABTestResponse(int abTestScheduleID) + { + AbTestScheduleID = abTestScheduleID; + } + + /// + /// Unique scheduled A/B test identifier. + /// + /// Unique scheduled A/B test identifier. + [JsonPropertyName("abTestScheduleID")] + public int AbTestScheduleID { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ScheduleABTestResponse {\n"); + sb.Append(" AbTestScheduleID: ").Append(AbTestScheduleID).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return JsonSerializer.Serialize(this, JsonConfig.Options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is not ScheduleABTestResponse input) + { + return false; + } + + return + (AbTestScheduleID == input.AbTestScheduleID || AbTestScheduleID.Equals(input.AbTestScheduleID)); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + AbTestScheduleID.GetHashCode(); + return hashCode; + } + } + +} + diff --git a/algoliasearch/Models/Abtesting/ScheduleABTestsRequest.cs b/algoliasearch/Models/Abtesting/ScheduleABTestsRequest.cs new file mode 100644 index 000000000..708fc896e --- /dev/null +++ b/algoliasearch/Models/Abtesting/ScheduleABTestsRequest.cs @@ -0,0 +1,141 @@ +// +// 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; + +/// +/// ScheduleABTestsRequest +/// +public partial class ScheduleABTestsRequest +{ + /// + /// Initializes a new instance of the ScheduleABTestsRequest class. + /// + [JsonConstructor] + public ScheduleABTestsRequest() { } + /// + /// Initializes a new instance of the ScheduleABTestsRequest class. + /// + /// A/B test name. (required). + /// A/B test variants. (required). + /// Date and time when the A/B test is scheduled to start, in RFC 3339 format. (required). + /// End date and time of the A/B test, in RFC 3339 format. (required). + public ScheduleABTestsRequest(string name, List variants, string scheduledAt, string endAt) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + Variants = variants ?? throw new ArgumentNullException(nameof(variants)); + ScheduledAt = scheduledAt ?? throw new ArgumentNullException(nameof(scheduledAt)); + EndAt = endAt ?? throw new ArgumentNullException(nameof(endAt)); + } + + /// + /// A/B test name. + /// + /// A/B test name. + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// A/B test variants. + /// + /// A/B test variants. + [JsonPropertyName("variants")] + public List Variants { get; set; } + + /// + /// Date and time when the A/B test is scheduled to start, in RFC 3339 format. + /// + /// Date and time when the A/B test is scheduled to start, in RFC 3339 format. + [JsonPropertyName("scheduledAt")] + public string ScheduledAt { get; set; } + + /// + /// End date and time of the A/B test, in RFC 3339 format. + /// + /// End date and time of the A/B test, in RFC 3339 format. + [JsonPropertyName("endAt")] + public string EndAt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ScheduleABTestsRequest {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" Variants: ").Append(Variants).Append("\n"); + sb.Append(" ScheduledAt: ").Append(ScheduledAt).Append("\n"); + sb.Append(" EndAt: ").Append(EndAt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return JsonSerializer.Serialize(this, JsonConfig.Options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is not ScheduleABTestsRequest input) + { + return false; + } + + return + (Name == input.Name || (Name != null && Name.Equals(input.Name))) && + (Variants == input.Variants || Variants != null && input.Variants != null && Variants.SequenceEqual(input.Variants)) && + (ScheduledAt == input.ScheduledAt || (ScheduledAt != null && ScheduledAt.Equals(input.ScheduledAt))) && + (EndAt == input.EndAt || (EndAt != null && EndAt.Equals(input.EndAt))); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (Name != null) + { + hashCode = (hashCode * 59) + Name.GetHashCode(); + } + if (Variants != null) + { + hashCode = (hashCode * 59) + Variants.GetHashCode(); + } + if (ScheduledAt != null) + { + hashCode = (hashCode * 59) + ScheduledAt.GetHashCode(); + } + if (EndAt != null) + { + hashCode = (hashCode * 59) + EndAt.GetHashCode(); + } + return hashCode; + } + } + +} +