Skip to content

Commit ba8623a

Browse files
feat(specs): add secrets authentications to ingestion (generated)
algolia/api-clients-automation#4054 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 5b691cf commit ba8623a

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

algoliasearch/Models/Ingestion/AuthInput.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ public AuthInput(AuthAlgoliaInsights actualInstance)
8080
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
8181
}
8282

83+
/// <summary>
84+
/// Initializes a new instance of the AuthInput class
85+
/// with a Dictionary{string, string}
86+
/// </summary>
87+
/// <param name="actualInstance">An instance of Dictionary&lt;string, string&gt;.</param>
88+
public AuthInput(Dictionary<string, string> actualInstance)
89+
{
90+
ActualInstance = actualInstance;
91+
}
92+
8393

8494
/// <summary>
8595
/// Gets or Sets ActualInstance
@@ -146,6 +156,16 @@ public AuthAlgoliaInsights AsAuthAlgoliaInsights()
146156
return (AuthAlgoliaInsights)ActualInstance;
147157
}
148158

159+
/// <summary>
160+
/// Get the actual instance of `Dictionary{string, string}`. If the actual instance is not `Dictionary{string, string}`,
161+
/// the InvalidClassException will be thrown
162+
/// </summary>
163+
/// <returns>An instance of Dictionary&lt;string, string&gt;</returns>
164+
public Dictionary<string, string> AsDictionaryString()
165+
{
166+
return (Dictionary<string, string>)ActualInstance;
167+
}
168+
149169

150170
/// <summary>
151171
/// Check if the actual instance is of `AuthOAuth` type.
@@ -201,6 +221,15 @@ public bool IsAuthAlgoliaInsights()
201221
return ActualInstance.GetType() == typeof(AuthAlgoliaInsights);
202222
}
203223

224+
/// <summary>
225+
/// Check if the actual instance is of `Dictionary{string, string}` type.
226+
/// </summary>
227+
/// <returns>Whether or not the instance is the type</returns>
228+
public bool IsDictionaryString()
229+
{
230+
return ActualInstance.GetType() == typeof(Dictionary<string, string>);
231+
}
232+
204233
/// <summary>
205234
/// Returns the string presentation of the object
206235
/// </summary>
@@ -357,6 +386,18 @@ public override AuthInput Read(ref Utf8JsonReader reader, Type typeToConvert, Js
357386
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into AuthAlgoliaInsights: {exception}");
358387
}
359388
}
389+
if (root.ValueKind == JsonValueKind.Object)
390+
{
391+
try
392+
{
393+
return new AuthInput(jsonDocument.Deserialize<Dictionary<string, string>>(JsonConfig.Options));
394+
}
395+
catch (Exception exception)
396+
{
397+
// deserialization failed, try the next one
398+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into Dictionary<string, string>: {exception}");
399+
}
400+
}
360401
throw new InvalidDataException($"The JSON string cannot be deserialized into any schema defined.");
361402
}
362403

algoliasearch/Models/Ingestion/AuthenticationType.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public enum AuthenticationType
5252
/// Enum AlgoliaInsights for value: algoliaInsights
5353
/// </summary>
5454
[JsonPropertyName("algoliaInsights")]
55-
AlgoliaInsights = 6
55+
AlgoliaInsights = 6,
56+
57+
/// <summary>
58+
/// Enum Secrets for value: secrets
59+
/// </summary>
60+
[JsonPropertyName("secrets")]
61+
Secrets = 7
5662
}
5763

0 commit comments

Comments
 (0)