Skip to content

Commit 26e0ccb

Browse files
feat(specs): add put task endpoint to ingestion api (generated)
algolia/api-clients-automation#5281 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent d41d56d commit 26e0ccb

File tree

3 files changed

+286
-3
lines changed

3 files changed

+286
-3
lines changed

algoliasearch/Clients/IngestionClient.cs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,42 @@ WatchResponse PushTask(
17881788
CancellationToken cancellationToken = default
17891789
);
17901790

1791+
/// <summary>
1792+
/// Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
1793+
/// </summary>
1794+
/// <param name="taskID">Unique identifier of a task.</param>
1795+
/// <param name="taskReplace"></param>
1796+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
1797+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
1798+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
1799+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
1800+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
1801+
/// <returns>Task of TaskUpdateResponse</returns>
1802+
Task<TaskUpdateResponse> ReplaceTaskAsync(
1803+
string taskID,
1804+
TaskReplace taskReplace,
1805+
RequestOptions options = null,
1806+
CancellationToken cancellationToken = default
1807+
);
1808+
1809+
/// <summary>
1810+
/// Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields. (Synchronous version)
1811+
/// </summary>
1812+
/// <param name="taskID">Unique identifier of a task.</param>
1813+
/// <param name="taskReplace"></param>
1814+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
1815+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
1816+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
1817+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
1818+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
1819+
/// <returns>TaskUpdateResponse</returns>
1820+
TaskUpdateResponse ReplaceTask(
1821+
string taskID,
1822+
TaskReplace taskReplace,
1823+
RequestOptions options = null,
1824+
CancellationToken cancellationToken = default
1825+
);
1826+
17911827
/// <summary>
17921828
/// Runs all tasks linked to a source, only available for Shopify, BigCommerce and commercetools sources. Creates one run per task.
17931829
/// </summary>
@@ -2451,7 +2487,7 @@ SourceUpdateResponse UpdateSource(
24512487
);
24522488

24532489
/// <summary>
2454-
/// Updates a task by its ID.
2490+
/// Partially updates a task by its ID.
24552491
/// </summary>
24562492
/// <param name="taskID">Unique identifier of a task.</param>
24572493
/// <param name="taskUpdate"></param>
@@ -2469,7 +2505,7 @@ Task<TaskUpdateResponse> UpdateTaskAsync(
24692505
);
24702506

24712507
/// <summary>
2472-
/// Updates a task by its ID. (Synchronous version)
2508+
/// Partially updates a task by its ID. (Synchronous version)
24732509
/// </summary>
24742510
/// <param name="taskID">Unique identifier of a task.</param>
24752511
/// <param name="taskUpdate"></param>
@@ -4265,6 +4301,45 @@ public WatchResponse PushTask(
42654301
PushTaskAsync(taskID, pushTaskPayload, watch, options, cancellationToken)
42664302
);
42674303

4304+
/// <inheritdoc />
4305+
public async Task<TaskUpdateResponse> ReplaceTaskAsync(
4306+
string taskID,
4307+
TaskReplace taskReplace,
4308+
RequestOptions options = null,
4309+
CancellationToken cancellationToken = default
4310+
)
4311+
{
4312+
if (taskID == null)
4313+
throw new ArgumentException("Parameter `taskID` is required when calling `ReplaceTask`.");
4314+
4315+
if (taskReplace == null)
4316+
throw new ArgumentException(
4317+
"Parameter `taskReplace` is required when calling `ReplaceTask`."
4318+
);
4319+
4320+
var requestOptions = new InternalRequestOptions(options);
4321+
4322+
requestOptions.PathParameters.Add("taskID", QueryStringHelper.ParameterToString(taskID));
4323+
4324+
requestOptions.Data = taskReplace;
4325+
return await _transport
4326+
.ExecuteRequestAsync<TaskUpdateResponse>(
4327+
new HttpMethod("PUT"),
4328+
"/2/tasks/{taskID}",
4329+
requestOptions,
4330+
cancellationToken
4331+
)
4332+
.ConfigureAwait(false);
4333+
}
4334+
4335+
/// <inheritdoc />
4336+
public TaskUpdateResponse ReplaceTask(
4337+
string taskID,
4338+
TaskReplace taskReplace,
4339+
RequestOptions options = null,
4340+
CancellationToken cancellationToken = default
4341+
) => AsyncHelper.RunSync(() => ReplaceTaskAsync(taskID, taskReplace, options, cancellationToken));
4342+
42684343
/// <inheritdoc />
42694344
public async Task<RunSourceResponse> RunSourceAsync(
42704345
string sourceID,
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
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.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Text.Json;
9+
using System.Text.Json.Serialization;
10+
using Algolia.Search.Serializer;
11+
12+
namespace Algolia.Search.Models.Ingestion;
13+
14+
/// <summary>
15+
/// API request body for updating a task.
16+
/// </summary>
17+
public partial class TaskReplace
18+
{
19+
/// <summary>
20+
/// Gets or Sets Action
21+
/// </summary>
22+
[JsonPropertyName("action")]
23+
public ActionType? Action { get; set; }
24+
25+
/// <summary>
26+
/// Gets or Sets SubscriptionAction
27+
/// </summary>
28+
[JsonPropertyName("subscriptionAction")]
29+
public ActionType? SubscriptionAction { get; set; }
30+
31+
/// <summary>
32+
/// Initializes a new instance of the TaskReplace class.
33+
/// </summary>
34+
[JsonConstructor]
35+
public TaskReplace() { }
36+
37+
/// <summary>
38+
/// Initializes a new instance of the TaskReplace class.
39+
/// </summary>
40+
/// <param name="destinationID">Universally unique identifier (UUID) of a destination resource. (required).</param>
41+
/// <param name="action">action (required).</param>
42+
public TaskReplace(string destinationID, ActionType? action)
43+
{
44+
DestinationID = destinationID ?? throw new ArgumentNullException(nameof(destinationID));
45+
Action = action;
46+
}
47+
48+
/// <summary>
49+
/// Universally unique identifier (UUID) of a destination resource.
50+
/// </summary>
51+
/// <value>Universally unique identifier (UUID) of a destination resource.</value>
52+
[JsonPropertyName("destinationID")]
53+
public string DestinationID { get; set; }
54+
55+
/// <summary>
56+
/// Cron expression for the task's schedule.
57+
/// </summary>
58+
/// <value>Cron expression for the task's schedule.</value>
59+
[JsonPropertyName("cron")]
60+
public string Cron { get; set; }
61+
62+
/// <summary>
63+
/// Whether the task is enabled.
64+
/// </summary>
65+
/// <value>Whether the task is enabled.</value>
66+
[JsonPropertyName("enabled")]
67+
public bool? Enabled { get; set; }
68+
69+
/// <summary>
70+
/// Maximum accepted percentage of failures for a task run to finish successfully.
71+
/// </summary>
72+
/// <value>Maximum accepted percentage of failures for a task run to finish successfully.</value>
73+
[JsonPropertyName("failureThreshold")]
74+
public int? FailureThreshold { get; set; }
75+
76+
/// <summary>
77+
/// Gets or Sets Input
78+
/// </summary>
79+
[JsonPropertyName("input")]
80+
public TaskInput Input { get; set; }
81+
82+
/// <summary>
83+
/// Date of the last cursor in RFC 3339 format.
84+
/// </summary>
85+
/// <value>Date of the last cursor in RFC 3339 format.</value>
86+
[JsonPropertyName("cursor")]
87+
public string Cursor { get; set; }
88+
89+
/// <summary>
90+
/// Gets or Sets Notifications
91+
/// </summary>
92+
[JsonPropertyName("notifications")]
93+
public Notifications Notifications { get; set; }
94+
95+
/// <summary>
96+
/// Gets or Sets Policies
97+
/// </summary>
98+
[JsonPropertyName("policies")]
99+
public Policies Policies { get; set; }
100+
101+
/// <summary>
102+
/// Returns the string presentation of the object
103+
/// </summary>
104+
/// <returns>String presentation of the object</returns>
105+
public override string ToString()
106+
{
107+
StringBuilder sb = new StringBuilder();
108+
sb.Append("class TaskReplace {\n");
109+
sb.Append(" DestinationID: ").Append(DestinationID).Append("\n");
110+
sb.Append(" Action: ").Append(Action).Append("\n");
111+
sb.Append(" SubscriptionAction: ").Append(SubscriptionAction).Append("\n");
112+
sb.Append(" Cron: ").Append(Cron).Append("\n");
113+
sb.Append(" Enabled: ").Append(Enabled).Append("\n");
114+
sb.Append(" FailureThreshold: ").Append(FailureThreshold).Append("\n");
115+
sb.Append(" Input: ").Append(Input).Append("\n");
116+
sb.Append(" Cursor: ").Append(Cursor).Append("\n");
117+
sb.Append(" Notifications: ").Append(Notifications).Append("\n");
118+
sb.Append(" Policies: ").Append(Policies).Append("\n");
119+
sb.Append("}\n");
120+
return sb.ToString();
121+
}
122+
123+
/// <summary>
124+
/// Returns the JSON string presentation of the object
125+
/// </summary>
126+
/// <returns>JSON string presentation of the object</returns>
127+
public virtual string ToJson()
128+
{
129+
return JsonSerializer.Serialize(this, JsonConfig.Options);
130+
}
131+
132+
/// <summary>
133+
/// Returns true if objects are equal
134+
/// </summary>
135+
/// <param name="obj">Object to be compared</param>
136+
/// <returns>Boolean</returns>
137+
public override bool Equals(object obj)
138+
{
139+
if (obj is not TaskReplace input)
140+
{
141+
return false;
142+
}
143+
144+
return (
145+
DestinationID == input.DestinationID
146+
|| (DestinationID != null && DestinationID.Equals(input.DestinationID))
147+
)
148+
&& (Action == input.Action || Action.Equals(input.Action))
149+
&& (
150+
SubscriptionAction == input.SubscriptionAction
151+
|| SubscriptionAction.Equals(input.SubscriptionAction)
152+
)
153+
&& (Cron == input.Cron || (Cron != null && Cron.Equals(input.Cron)))
154+
&& (Enabled == input.Enabled || Enabled.Equals(input.Enabled))
155+
&& (
156+
FailureThreshold == input.FailureThreshold
157+
|| FailureThreshold.Equals(input.FailureThreshold)
158+
)
159+
&& (Input == input.Input || (Input != null && Input.Equals(input.Input)))
160+
&& (Cursor == input.Cursor || (Cursor != null && Cursor.Equals(input.Cursor)))
161+
&& (
162+
Notifications == input.Notifications
163+
|| (Notifications != null && Notifications.Equals(input.Notifications))
164+
)
165+
&& (Policies == input.Policies || (Policies != null && Policies.Equals(input.Policies)));
166+
}
167+
168+
/// <summary>
169+
/// Gets the hash code
170+
/// </summary>
171+
/// <returns>Hash code</returns>
172+
public override int GetHashCode()
173+
{
174+
unchecked // Overflow is fine, just wrap
175+
{
176+
int hashCode = 41;
177+
if (DestinationID != null)
178+
{
179+
hashCode = (hashCode * 59) + DestinationID.GetHashCode();
180+
}
181+
hashCode = (hashCode * 59) + Action.GetHashCode();
182+
hashCode = (hashCode * 59) + SubscriptionAction.GetHashCode();
183+
if (Cron != null)
184+
{
185+
hashCode = (hashCode * 59) + Cron.GetHashCode();
186+
}
187+
hashCode = (hashCode * 59) + Enabled.GetHashCode();
188+
hashCode = (hashCode * 59) + FailureThreshold.GetHashCode();
189+
if (Input != null)
190+
{
191+
hashCode = (hashCode * 59) + Input.GetHashCode();
192+
}
193+
if (Cursor != null)
194+
{
195+
hashCode = (hashCode * 59) + Cursor.GetHashCode();
196+
}
197+
if (Notifications != null)
198+
{
199+
hashCode = (hashCode * 59) + Notifications.GetHashCode();
200+
}
201+
if (Policies != null)
202+
{
203+
hashCode = (hashCode * 59) + Policies.GetHashCode();
204+
}
205+
return hashCode;
206+
}
207+
}
208+
}

algoliasearch/Models/Ingestion/TaskUpdate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Algolia.Search.Models.Ingestion;
1313

1414
/// <summary>
15-
/// API request body for updating a task.
15+
/// API request body for partially updating a task.
1616
/// </summary>
1717
public partial class TaskUpdate
1818
{

0 commit comments

Comments
 (0)