Skip to content

Commit

Permalink
fix(specs): add secrets payload for updates (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4061

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Oct 31, 2024
1 parent 26c3f55 commit b7a614c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions algoliasearch/Models/Ingestion/AuthInputPartial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public AuthInputPartial(AuthAlgoliaInsightsPartial actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

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


/// <summary>
/// Gets or Sets ActualInstance
Expand Down Expand Up @@ -146,6 +156,16 @@ public AuthAlgoliaInsightsPartial AsAuthAlgoliaInsightsPartial()
return (AuthAlgoliaInsightsPartial)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 `AuthGoogleServiceAccountPartial` type.
Expand Down Expand Up @@ -201,6 +221,15 @@ public bool IsAuthAlgoliaInsightsPartial()
return ActualInstance.GetType() == typeof(AuthAlgoliaInsightsPartial);
}

/// <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 AuthInputPartial Read(ref Utf8JsonReader reader, Type typeToConv
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into AuthAlgoliaInsightsPartial: {exception}");
}
}
if (root.ValueKind == JsonValueKind.Object)
{
try
{
return new AuthInputPartial(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

0 comments on commit b7a614c

Please sign in to comment.