Skip to content

Re-generated client code using latest OpenSearch API specification #907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ApiGenerator/Domain/Code/CsharpNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public string PerPathMethodName(string path)
if (Namespace == "Nodes" && !pc("{node_id}"))
return (method + "ForAll").Replace("AsyncForAll", "ForAllAsync");

if (Namespace == "Knn" && method.StartsWith("Stats") && !pc("{node_id}"))
if (Namespace is "Knn" or "Ltr" && method.StartsWith("Stats") && !pc("{node_id}"))
return method.Replace("Stats", "StatsForAll");

if (Namespace == "Ml" && method == "GetStats" && !pc("{node_id}"))
Expand Down
6 changes: 0 additions & 6 deletions src/ApiGenerator/Generator/ApiEndpointFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,6 @@ private static string GetOpenSearchType(JsonSchema schema, Action<string, bool>

if (oneOf.Length != 2) throw new Exception("Unable to determine type of oneOf");

if (oneOf[0].Type == JsonObjectType.Boolean && oneOf[1].IsEnum())
{
trackEnumToGenerate(schemaKey, isListContext);
return CsharpNames.GetEnumName(schemaKey) + "?";
}

var first = GetOpenSearchType(oneOf[0], trackEnumToGenerate);
var second = GetOpenSearchType(oneOf[1], trackEnumToGenerate);
if (first.EndsWith("?")) return first;
Expand Down
19 changes: 16 additions & 3 deletions src/ApiGenerator/Generator/OpenApiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@ public static class OpenApiUtils

public static bool IsEnum(this JsonSchema schema)
{
if (schema.Type == JsonObjectType.String)
return schema.Enumeration.Count > 0 || schema.Const<string>() != null;
if (!schema.HasOneOf())
return schema.Type == JsonObjectType.String && (schema.Enumeration.Count > 0 || schema.Const<string>() != null);

return schema.HasOneOf() && schema.OneOf.All(IsEnum);
var enumCount = 0;
var booleanCount = 0;
var totalCount = 0;

foreach (var s in schema.OneOf)
{
if (s.Type == JsonObjectType.Boolean)
booleanCount++;
else if (s.IsEnum()) enumCount++;

totalCount++;
}

return enumCount == totalCount || (booleanCount == 1 && enumCount == totalCount - 1);
}

public static IImmutableList<string> GetEnumValues(this JsonSchema schema)
Expand Down
2,149 changes: 1,568 additions & 581 deletions src/ApiGenerator/opensearch-openapi.yaml

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/OpenSearch.Client/_Generated/Descriptors.Ingest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected DeletePipelineDescriptor()
Id IDeletePipelineRequest.Id => Self.RouteValues.Get<Id>("id");

// Request parameters
/// <summary>Operation timeout for connection to cluster-manager node.</summary>
/// <summary>The amount of time allowed to establish a connection to the cluster manager node.</summary>
/// <remarks>Supported by OpenSearch servers of version 2.0.0 or greater.</remarks>
public DeletePipelineDescriptor ClusterManagerTimeout(Time clustermanagertimeout) =>
Qs("cluster_manager_timeout", clustermanagertimeout);
Expand All @@ -94,7 +94,7 @@ public DeletePipelineDescriptor ClusterManagerTimeout(Time clustermanagertimeout
public DeletePipelineDescriptor MasterTimeout(Time mastertimeout) =>
Qs("master_timeout", mastertimeout);

/// <summary>Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.</summary>
/// <summary>The amount of time to wait for a response.</summary>
public DeletePipelineDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
}

Expand All @@ -121,12 +121,12 @@ public GetPipelineDescriptor(Id id)
// values part of the url path
Id IGetPipelineRequest.Id => Self.RouteValues.Get<Id>("id");

/// <summary>Comma-separated list of pipeline IDs to retrieve. Wildcard (`*`) expressions are supported. To get all ingest pipelines, omit this parameter or use `*`.</summary>
/// <summary>A comma-separated list of pipeline IDs to retrieve. Wildcard (`*`) expressions are supported. To get all ingest pipelines, omit this parameter or use `*`.</summary>
public GetPipelineDescriptor Id(Id id) =>
Assign(id, (a, v) => a.RouteValues.Optional("id", v));

// Request parameters
/// <summary>Operation timeout for connection to cluster-manager node.</summary>
/// <summary>The amount of time allowed to establish a connection to the cluster manager node.</summary>
/// <remarks>Supported by OpenSearch servers of version 2.0.0 or greater.</remarks>
public GetPipelineDescriptor ClusterManagerTimeout(Time clustermanagertimeout) =>
Qs("cluster_manager_timeout", clustermanagertimeout);
Expand All @@ -152,7 +152,7 @@ public partial class GrokProcessorPatternsDescriptor

// values part of the url path
// Request parameters
/// <summary>Sort returned patterns by key name.</summary>
/// <summary>Determines how to sort returned grok patterns by key name.</summary>
public GrokProcessorPatternsDescriptor SortByColumns(bool? sortbycolumns = true) =>
Qs("s", sortbycolumns);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ protected PutPipelineDescriptor()
Id IPutPipelineRequest.Id => Self.RouteValues.Get<Id>("id");

// Request parameters
/// <summary>Operation timeout for connection to cluster-manager node.</summary>
/// <summary>The amount of time allowed to establish a connection to the cluster manager node.</summary>
/// <remarks>Supported by OpenSearch servers of version 2.0.0 or greater.</remarks>
public PutPipelineDescriptor ClusterManagerTimeout(Time clustermanagertimeout) =>
Qs("cluster_manager_timeout", clustermanagertimeout);
Expand All @@ -194,7 +194,7 @@ public PutPipelineDescriptor ClusterManagerTimeout(Time clustermanagertimeout) =
public PutPipelineDescriptor MasterTimeout(Time mastertimeout) =>
Qs("master_timeout", mastertimeout);

/// <summary>Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.</summary>
/// <summary>The amount of time to wait for a response.</summary>
public PutPipelineDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
}

Expand All @@ -221,12 +221,12 @@ public SimulatePipelineDescriptor(Id id)
// values part of the url path
Id ISimulatePipelineRequest.Id => Self.RouteValues.Get<Id>("id");

/// <summary>Pipeline to test. If you don't specify a `pipeline` in the request body, this parameter is required.</summary>
/// <summary>The pipeline to test. If you don't specify a `pipeline` in the request body, this parameter is required.</summary>
public SimulatePipelineDescriptor Id(Id id) =>
Assign(id, (a, v) => a.RouteValues.Optional("id", v));

// Request parameters
/// <summary>If `true`, the response includes output data for each processor in the executed pipeline.</summary>
/// <summary>When `true`, the response includes output data for each processor in the pipeline.</summary>
public SimulatePipelineDescriptor Verbose(bool? verbose = true) => Qs("verbose", verbose);
}
}
Loading
Loading