Skip to content

Commit

Permalink
feat(specs): only use shortname in the source input [skip-bc] (genera…
Browse files Browse the repository at this point in the history
…ted)

algolia/api-clients-automation#4287

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
algolia-bot and millotp committed Jan 8, 2025
1 parent 8c768bb commit c007457
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 166 deletions.
33 changes: 0 additions & 33 deletions algoliasearch/Models/Ingestion/DockerImageType.cs

This file was deleted.

33 changes: 0 additions & 33 deletions algoliasearch/Models/Ingestion/DockerRegistry.cs

This file was deleted.

43 changes: 4 additions & 39 deletions algoliasearch/Models/Ingestion/SourceDocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ namespace Algolia.Search.Models.Ingestion;
/// </summary>
public partial class SourceDocker
{

/// <summary>
/// Gets or Sets ImageType
/// </summary>
[JsonPropertyName("imageType")]
public DockerImageType? ImageType { get; set; }

/// <summary>
/// Gets or Sets Registry
/// </summary>
[JsonPropertyName("registry")]
public DockerRegistry? Registry { get; set; }
/// <summary>
/// Initializes a new instance of the SourceDocker class.
/// </summary>
Expand All @@ -36,32 +24,21 @@ public SourceDocker() { }
/// <summary>
/// Initializes a new instance of the SourceDocker class.
/// </summary>
/// <param name="imageType">imageType (required).</param>
/// <param name="registry">registry (required).</param>
/// <param name="image">Docker image name. (required).</param>
/// <param name="image">Shortname of the image, as returned by the referential. (required).</param>
/// <param name="configuration">Configuration of the spec. (required).</param>
public SourceDocker(DockerImageType? imageType, DockerRegistry? registry, string image, object configuration)
public SourceDocker(string image, object configuration)
{
ImageType = imageType;
Registry = registry;
Image = image ?? throw new ArgumentNullException(nameof(image));
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
}

/// <summary>
/// Docker image name.
/// Shortname of the image, as returned by the referential.
/// </summary>
/// <value>Docker image name.</value>
/// <value>Shortname of the image, as returned by the referential.</value>
[JsonPropertyName("image")]
public string Image { get; set; }

/// <summary>
/// Docker image version.
/// </summary>
/// <value>Docker image version.</value>
[JsonPropertyName("version")]
public string VarVersion { get; set; }

/// <summary>
/// Configuration of the spec.
/// </summary>
Expand All @@ -77,10 +54,7 @@ public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class SourceDocker {\n");
sb.Append(" ImageType: ").Append(ImageType).Append("\n");
sb.Append(" Registry: ").Append(Registry).Append("\n");
sb.Append(" Image: ").Append(Image).Append("\n");
sb.Append(" VarVersion: ").Append(VarVersion).Append("\n");
sb.Append(" Configuration: ").Append(Configuration).Append("\n");
sb.Append("}\n");
return sb.ToString();
Expand Down Expand Up @@ -108,10 +82,7 @@ public override bool Equals(object obj)
}

return
(ImageType == input.ImageType || ImageType.Equals(input.ImageType)) &&
(Registry == input.Registry || Registry.Equals(input.Registry)) &&
(Image == input.Image || (Image != null && Image.Equals(input.Image))) &&
(VarVersion == input.VarVersion || (VarVersion != null && VarVersion.Equals(input.VarVersion))) &&
(Configuration == input.Configuration || (Configuration != null && Configuration.Equals(input.Configuration)));
}

Expand All @@ -124,16 +95,10 @@ public override int GetHashCode()
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
hashCode = (hashCode * 59) + ImageType.GetHashCode();
hashCode = (hashCode * 59) + Registry.GetHashCode();
if (Image != null)
{
hashCode = (hashCode * 59) + Image.GetHashCode();
}
if (VarVersion != null)
{
hashCode = (hashCode * 59) + VarVersion.GetHashCode();
}
if (Configuration != null)
{
hashCode = (hashCode * 59) + Configuration.GetHashCode();
Expand Down
52 changes: 26 additions & 26 deletions algoliasearch/Models/Ingestion/SourceInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ public partial class SourceInput : AbstractSchema
{
/// <summary>
/// Initializes a new instance of the SourceInput class
/// with a SourceDocker
/// with a SourceGA4BigQueryExport
/// </summary>
/// <param name="actualInstance">An instance of SourceDocker.</param>
public SourceInput(SourceDocker actualInstance)
/// <param name="actualInstance">An instance of SourceGA4BigQueryExport.</param>
public SourceInput(SourceGA4BigQueryExport actualInstance)
{
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the SourceInput class
/// with a SourceGA4BigQueryExport
/// with a SourceDocker
/// </summary>
/// <param name="actualInstance">An instance of SourceGA4BigQueryExport.</param>
public SourceInput(SourceGA4BigQueryExport actualInstance)
/// <param name="actualInstance">An instance of SourceDocker.</param>
public SourceInput(SourceDocker actualInstance)
{
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}
Expand Down Expand Up @@ -107,23 +107,23 @@ public SourceInput(SourceCSV actualInstance)
public sealed override object ActualInstance { get; set; }

/// <summary>
/// Get the actual instance of `SourceDocker`. If the actual instance is not `SourceDocker`,
/// Get the actual instance of `SourceGA4BigQueryExport`. If the actual instance is not `SourceGA4BigQueryExport`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of SourceDocker</returns>
public SourceDocker AsSourceDocker()
/// <returns>An instance of SourceGA4BigQueryExport</returns>
public SourceGA4BigQueryExport AsSourceGA4BigQueryExport()
{
return (SourceDocker)ActualInstance;
return (SourceGA4BigQueryExport)ActualInstance;
}

/// <summary>
/// Get the actual instance of `SourceGA4BigQueryExport`. If the actual instance is not `SourceGA4BigQueryExport`,
/// Get the actual instance of `SourceDocker`. If the actual instance is not `SourceDocker`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of SourceGA4BigQueryExport</returns>
public SourceGA4BigQueryExport AsSourceGA4BigQueryExport()
/// <returns>An instance of SourceDocker</returns>
public SourceDocker AsSourceDocker()
{
return (SourceGA4BigQueryExport)ActualInstance;
return (SourceDocker)ActualInstance;
}

/// <summary>
Expand Down Expand Up @@ -188,21 +188,21 @@ public SourceCSV AsSourceCSV()


/// <summary>
/// Check if the actual instance is of `SourceDocker` type.
/// Check if the actual instance is of `SourceGA4BigQueryExport` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsSourceDocker()
public bool IsSourceGA4BigQueryExport()
{
return ActualInstance.GetType() == typeof(SourceDocker);
return ActualInstance.GetType() == typeof(SourceGA4BigQueryExport);
}

/// <summary>
/// Check if the actual instance is of `SourceGA4BigQueryExport` type.
/// Check if the actual instance is of `SourceDocker` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsSourceGA4BigQueryExport()
public bool IsSourceDocker()
{
return ActualInstance.GetType() == typeof(SourceGA4BigQueryExport);
return ActualInstance.GetType() == typeof(SourceDocker);
}

/// <summary>
Expand Down Expand Up @@ -343,28 +343,28 @@ public override SourceInput Read(ref Utf8JsonReader reader, Type typeToConvert,
{
var jsonDocument = JsonDocument.ParseValue(ref reader);
var root = jsonDocument.RootElement;
if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("registry", out _) && root.TryGetProperty("image", out _) && root.TryGetProperty("imageType", out _) && root.TryGetProperty("configuration", out _))
if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("projectID", out _) && root.TryGetProperty("datasetID", out _) && root.TryGetProperty("tablePrefix", out _))
{
try
{
return new SourceInput(jsonDocument.Deserialize<SourceDocker>(JsonConfig.Options));
return new SourceInput(jsonDocument.Deserialize<SourceGA4BigQueryExport>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into SourceDocker: {exception}");
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into SourceGA4BigQueryExport: {exception}");
}
}
if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("projectID", out _) && root.TryGetProperty("datasetID", out _) && root.TryGetProperty("tablePrefix", out _))
if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("image", out _) && root.TryGetProperty("configuration", out _))
{
try
{
return new SourceInput(jsonDocument.Deserialize<SourceGA4BigQueryExport>(JsonConfig.Options));
return new SourceInput(jsonDocument.Deserialize<SourceDocker>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into SourceGA4BigQueryExport: {exception}");
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into SourceDocker: {exception}");
}
}
if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("projectKey", out _))
Expand Down
35 changes: 0 additions & 35 deletions algoliasearch/Models/Ingestion/SourceUpdateDocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ namespace Algolia.Search.Models.Ingestion;
/// </summary>
public partial class SourceUpdateDocker
{

/// <summary>
/// Gets or Sets Registry
/// </summary>
[JsonPropertyName("registry")]
public DockerRegistry? Registry { get; set; }
/// <summary>
/// Initializes a new instance of the SourceUpdateDocker class.
/// </summary>
Expand All @@ -36,20 +30,6 @@ public SourceUpdateDocker(object configuration)
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
}

/// <summary>
/// Docker image name.
/// </summary>
/// <value>Docker image name.</value>
[JsonPropertyName("image")]
public string Image { get; set; }

/// <summary>
/// Docker image version.
/// </summary>
/// <value>Docker image version.</value>
[JsonPropertyName("version")]
public string VarVersion { get; set; }

/// <summary>
/// Configuration of the spec.
/// </summary>
Expand All @@ -65,9 +45,6 @@ public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class SourceUpdateDocker {\n");
sb.Append(" Registry: ").Append(Registry).Append("\n");
sb.Append(" Image: ").Append(Image).Append("\n");
sb.Append(" VarVersion: ").Append(VarVersion).Append("\n");
sb.Append(" Configuration: ").Append(Configuration).Append("\n");
sb.Append("}\n");
return sb.ToString();
Expand Down Expand Up @@ -95,9 +72,6 @@ public override bool Equals(object obj)
}

return
(Registry == input.Registry || Registry.Equals(input.Registry)) &&
(Image == input.Image || (Image != null && Image.Equals(input.Image))) &&
(VarVersion == input.VarVersion || (VarVersion != null && VarVersion.Equals(input.VarVersion))) &&
(Configuration == input.Configuration || (Configuration != null && Configuration.Equals(input.Configuration)));
}

Expand All @@ -110,15 +84,6 @@ public override int GetHashCode()
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
hashCode = (hashCode * 59) + Registry.GetHashCode();
if (Image != null)
{
hashCode = (hashCode * 59) + Image.GetHashCode();
}
if (VarVersion != null)
{
hashCode = (hashCode * 59) + VarVersion.GetHashCode();
}
if (Configuration != null)
{
hashCode = (hashCode * 59) + Configuration.GetHashCode();
Expand Down

0 comments on commit c007457

Please sign in to comment.