Skip to content

Commit

Permalink
feat(specs): add secrets authentications to ingestion (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4054

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
  • Loading branch information
algolia-bot and shortcuts committed Oct 30, 2024
1 parent 5b691cf commit ba8623a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
41 changes: 41 additions & 0 deletions algoliasearch/Models/Ingestion/AuthInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public AuthInput(AuthAlgoliaInsights actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the AuthInput class
/// with a Dictionary{string, string}
/// </summary>
/// <param name="actualInstance">An instance of Dictionary&lt;string, string&gt;.</param>
public AuthInput(Dictionary<string, string> actualInstance)
{
ActualInstance = actualInstance;
}


/// <summary>
/// Gets or Sets ActualInstance
Expand Down Expand Up @@ -146,6 +156,16 @@ public AuthAlgoliaInsights AsAuthAlgoliaInsights()
return (AuthAlgoliaInsights)ActualInstance;
}

/// <summary>
/// Get the actual instance of `Dictionary{string, string}`. If the actual instance is not `Dictionary{string, string}`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of Dictionary&lt;string, string&gt;</returns>
public Dictionary<string, string> AsDictionaryString()
{
return (Dictionary<string, string>)ActualInstance;
}


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

/// <summary>
/// Check if the actual instance is of `Dictionary{string, string}` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsDictionaryString()
{
return ActualInstance.GetType() == typeof(Dictionary<string, string>);
}

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand Down Expand Up @@ -357,6 +386,18 @@ public override AuthInput Read(ref Utf8JsonReader reader, Type typeToConvert, Js
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into AuthAlgoliaInsights: {exception}");
}
}
if (root.ValueKind == JsonValueKind.Object)
{
try
{
return new AuthInput(jsonDocument.Deserialize<Dictionary<string, string>>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into Dictionary<string, string>: {exception}");
}
}
throw new InvalidDataException($"The JSON string cannot be deserialized into any schema defined.");
}

Expand Down
8 changes: 7 additions & 1 deletion algoliasearch/Models/Ingestion/AuthenticationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public enum AuthenticationType
/// Enum AlgoliaInsights for value: algoliaInsights
/// </summary>
[JsonPropertyName("algoliaInsights")]
AlgoliaInsights = 6
AlgoliaInsights = 6,

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

0 comments on commit ba8623a

Please sign in to comment.