Skip to content

Commit

Permalink
feat(specs): add v2 endpoints for ingestion
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3416

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Jul 25, 2024
1 parent 2713196 commit 8663dc7
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 0 deletions.
81 changes: 81 additions & 0 deletions algoliasearch/Clients/IngestionClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,32 @@ public interface IIngestionClient
/// <returns>ListTransformationsResponse</returns>
ListTransformationsResponse ListTransformations(SortKeys? sort = default, OrderKeys? order = default, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints.
/// </summary>
/// <param name="taskID">Unique identifier of a task.</param>
/// <param name="batchWriteParams">Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.</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 RunResponse</returns>
Task<RunResponse> PushTaskAsync(string taskID, BatchWriteParams batchWriteParams, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints. (Synchronous version)
/// </summary>
/// <param name="taskID">Unique identifier of a task.</param>
/// <param name="batchWriteParams">Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.</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>RunResponse</returns>
RunResponse PushTask(string taskID, BatchWriteParams batchWriteParams, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Runs a task. You can check the status of task runs with the observability endpoints.
/// </summary>
Expand Down Expand Up @@ -3273,6 +3299,61 @@ public ListTransformationsResponse ListTransformations(SortKeys? sort = default,
AsyncHelper.RunSync(() => ListTransformationsAsync(sort, order, options, cancellationToken));


/// <summary>
/// Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints.
/// </summary>
///
/// Required API Key ACLs:
/// - addObject
/// - deleteIndex
/// - editSettings
/// <param name="taskID">Unique identifier of a task.</param>
/// <param name="batchWriteParams">Request body of a Search API &#x60;batch&#x60; request that will be pushed in the Connectors pipeline.</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 RunResponse</returns>
public async Task<RunResponse> PushTaskAsync(string taskID, BatchWriteParams batchWriteParams, RequestOptions options = null, CancellationToken cancellationToken = default)
{

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


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

var requestOptions = new InternalRequestOptions(options);

requestOptions.PathParameters.Add("taskID", QueryStringHelper.ParameterToString(taskID));

requestOptions.Data = batchWriteParams;
return await _transport.ExecuteRequestAsync<RunResponse>(new HttpMethod("POST"), "/2/tasks/{taskID}/push", requestOptions, cancellationToken).ConfigureAwait(false);
}


/// <summary>
/// Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints. (Synchronous version)
/// </summary>
///
/// Required API Key ACLs:
/// - addObject
/// - deleteIndex
/// - editSettings
/// <param name="taskID">Unique identifier of a task.</param>
/// <param name="batchWriteParams">Request body of a Search API &#x60;batch&#x60; request that will be pushed in the Connectors pipeline.</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>RunResponse</returns>
public RunResponse PushTask(string taskID, BatchWriteParams batchWriteParams, RequestOptions options = null, CancellationToken cancellationToken = default) =>
AsyncHelper.RunSync(() => PushTaskAsync(taskID, batchWriteParams, options, cancellationToken));


/// <summary>
/// Runs a task. You can check the status of task runs with the observability endpoints.
/// </summary>
Expand Down
62 changes: 62 additions & 0 deletions algoliasearch/Models/Ingestion/Action.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// 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.Ingestion;

/// <summary>
/// Type of indexing operation.
/// </summary>
/// <value>Type of indexing operation.</value>
public enum Action
{
/// <summary>
/// Enum AddObject for value: addObject
/// </summary>
[JsonPropertyName("addObject")]
AddObject = 1,

/// <summary>
/// Enum UpdateObject for value: updateObject
/// </summary>
[JsonPropertyName("updateObject")]
UpdateObject = 2,

/// <summary>
/// Enum PartialUpdateObject for value: partialUpdateObject
/// </summary>
[JsonPropertyName("partialUpdateObject")]
PartialUpdateObject = 3,

/// <summary>
/// Enum PartialUpdateObjectNoCreate for value: partialUpdateObjectNoCreate
/// </summary>
[JsonPropertyName("partialUpdateObjectNoCreate")]
PartialUpdateObjectNoCreate = 4,

/// <summary>
/// Enum DeleteObject for value: deleteObject
/// </summary>
[JsonPropertyName("deleteObject")]
DeleteObject = 5,

/// <summary>
/// Enum Delete for value: delete
/// </summary>
[JsonPropertyName("delete")]
Delete = 6,

/// <summary>
/// Enum Clear for value: clear
/// </summary>
[JsonPropertyName("clear")]
Clear = 7
}

107 changes: 107 additions & 0 deletions algoliasearch/Models/Ingestion/BatchRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//
// 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.Ingestion;

/// <summary>
/// BatchRequest
/// </summary>
public partial class BatchRequest
{

/// <summary>
/// Gets or Sets Action
/// </summary>
[JsonPropertyName("action")]
public Action? Action { get; set; }
/// <summary>
/// Initializes a new instance of the BatchRequest class.
/// </summary>
[JsonConstructor]
public BatchRequest() { }
/// <summary>
/// Initializes a new instance of the BatchRequest class.
/// </summary>
/// <param name="action">action (required).</param>
/// <param name="body">Operation arguments (varies with specified &#x60;action&#x60;). (required).</param>
public BatchRequest(Action? action, object body)
{
Action = action;
Body = body ?? throw new ArgumentNullException(nameof(body));
}

/// <summary>
/// Operation arguments (varies with specified `action`).
/// </summary>
/// <value>Operation arguments (varies with specified `action`).</value>
[JsonPropertyName("body")]
public object Body { 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 BatchRequest {\n");
sb.Append(" Action: ").Append(Action).Append("\n");
sb.Append(" Body: ").Append(Body).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 BatchRequest input)
{
return false;
}

return
(Action == input.Action || Action.Equals(input.Action)) &&
(Body == input.Body || (Body != null && Body.Equals(input.Body)));
}

/// <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) + Action.GetHashCode();
if (Body != null)
{
hashCode = (hashCode * 59) + Body.GetHashCode();
}
return hashCode;
}
}

}

95 changes: 95 additions & 0 deletions algoliasearch/Models/Ingestion/BatchWriteParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// 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.Ingestion;

/// <summary>
/// Batch parameters.
/// </summary>
public partial class BatchWriteParams
{
/// <summary>
/// Initializes a new instance of the BatchWriteParams class.
/// </summary>
[JsonConstructor]
public BatchWriteParams() { }
/// <summary>
/// Initializes a new instance of the BatchWriteParams class.
/// </summary>
/// <param name="requests">requests (required).</param>
public BatchWriteParams(List<BatchRequest> requests)
{
Requests = requests ?? throw new ArgumentNullException(nameof(requests));
}

/// <summary>
/// Gets or Sets Requests
/// </summary>
[JsonPropertyName("requests")]
public List<BatchRequest> Requests { 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 BatchWriteParams {\n");
sb.Append(" Requests: ").Append(Requests).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 BatchWriteParams input)
{
return false;
}

return
(Requests == input.Requests || Requests != null && input.Requests != null && Requests.SequenceEqual(input.Requests));
}

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

}

0 comments on commit 8663dc7

Please sign in to comment.