Skip to content
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

Re-generate indices namespace #803

Merged
merged 1 commit into from
Sep 18, 2024
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
12 changes: 12 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
#### Features Namespace
- The entire `Features` API namespace has been removed, there is no migration path as it was never supported by OpenSearch.

#### Indices.AddBlock Action
- The `block` parameter has been changed from a `string` to an `IndexApiBlock` enum.

#### Indices.Analyze Action
- The `IndexQueryString` parameter has been renamed to simply `Index`

#### Indices.ClearCache Action
- The `IndexQueryString` parameter has been renamed to simply `Index`

#### Indices.DeleteTemplateV2 Action
- This action has been removed in favour of the more descriptively named and typed `Indices.DeleteComposableTemplate` action.

Expand All @@ -91,6 +100,9 @@
#### Indices.PutTemplateV2 Action
- This action has been removed in favour of the more descriptively named and typed `Indices.PutComposableTemplate` action.

#### Indices.ShardStores Action
- The `Status` parameter now takes an `IndicesShardStoresShardStoreStatus` flag enum instead of a `string` array.

#### Nodes.HotThreads Action
- The `ThreadType` parameter has been renamed to just `Type` to match the query parameter it represents. Its corresponding `ThreadType` enum has been renamed to `NodesSampleType`.

Expand Down
21 changes: 16 additions & 5 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,36 @@
"version": "0.13.0",
"commands": [
"assembly-rewriter"
]
],
"rollForward": false
},
"assembly-differ": {
"version": "0.15.0",
"commands": [
"assembly-differ"
]
],
"rollForward": false
},
"nupkg-validator": {
"version": "0.6.0",
"commands": [
"nupkg-validator"
]
],
"rollForward": false
},
"release-notes": {
"version": "0.6.0",
"commands": [
"release-notes"
]
],
"rollForward": false
},
"csharpier": {
"version": "0.29.2",
"commands": [
"dotnet-csharpier"
],
"rollForward": false
}
}
}
}
13 changes: 6 additions & 7 deletions src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,19 @@ namespace ApiGenerator.Configuration
public static class CodeConfiguration
{
private static readonly Glob[] OperationsToInclude =
{
new("{create,delete}_pit"),
[
new("{create,delete}_pit"),
new("{delete,get}_all_pits"),

new("cat.*"),
new("cluster.*"),
new("dangling_indices.*"),

new("indices.{delete,exists,get,put}_index_template"),
new("indices.stats"),

new("indices.*"),
new("ingest.*"),
new("nodes.*"),
new("snapshot.*"),
new("tasks.*")
};
];

public static bool IncludeOperation(string name) => OperationsToInclude.Any(g => g.IsMatch(name));

Expand All @@ -62,6 +59,8 @@ public static class CodeConfiguration
/// </summary>
private static readonly Dictionary<string, string> LowLevelApiNameMapping = new()
{
{"indices.recovery", "RecoveryStatus"},
{"indices.shard_stores", "IndicesShardStores"}
};

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ private GlobalOverrides() { }

public IDictionary<string, string> RenameEnums { get; } = new Dictionary<string, string>
{
{ "ExpandWildcard", "ExpandWildcards" }
{ "ExpandWildcard", "ExpandWildcards" },
{ "QueryDslOperator", "DefaultOperator" },
{ "IndicesAddBlockIndicesBlockOptions", "IndexApiBlock" }
};

public override IDictionary<string, string> ObsoleteQueryStringParams { get; set; } = new Dictionary<string, string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* under the License.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using ApiGenerator.Domain.Specification;
Expand All @@ -51,18 +52,17 @@ public IEnumerable<FluentRouteSetter> GetFluentRouteSetters()
var parts = Parts
.Where(p => !p.Required || alwaysGenerate.Contains(p.Name))
.Where(p => !string.IsNullOrEmpty(p.Name))
.OrderBy(p => p.Name)
.ToList();
var returnType = CsharpNames.GenericOrNonGenericDescriptorName;
foreach (var part in parts)
foreach (var p in parts)
{
var p = part;
var paramName = p.Name.ToPascalCase();
if (paramName.Length > 1)
paramName = paramName.Substring(0, 1).ToLowerInvariant() + paramName.Substring(1);
else
paramName = paramName.ToLowerInvariant();
paramName = paramName.Length > 1
? string.Concat(paramName[..1].ToLowerInvariant(), paramName.AsSpan(1))
: paramName.ToLowerInvariant();

var routeValue = "v";
const string routeValue = "v";
var routeSetter = p.Required ? "Required" : "Optional";

var code =
Expand Down
1 change: 0 additions & 1 deletion src/ApiGenerator/Domain/Specification/UrlInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class UrlInformation
public IReadOnlyCollection<UrlPart> Parts => Paths
.SelectMany(p => p.Parts)
.DistinctBy(p => p.Name)
.OrderBy(p => p.Name)
.ToList();

public bool IsPartless => !Parts.Any();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</text>
}
// values part of the url path
@foreach (var part in Model.Parts)
@foreach (var part in Model.Parts.OrderBy(p => p.Name))
{
<text> @(Raw(part.HighLevelTypeName)) @(Raw(baseInterface)).@(part.InterfaceName) => Self.RouteValues.Get@(Raw(string.Format("<{0}>",part.HighLevelTypeName)))("@(part.Name)");
<text> @(Raw(part.HighLevelTypeName)) @(Raw(baseInterface)).@(part.InterfaceName) => Self.RouteValues.Get@(Raw($"<{part.HighLevelTypeName}>"))("@(part.Name)");
</text>
}
@foreach (var c in Model.GetFluentRouteSetters())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace OpenSearch.Client
var propertyName = $"{endpoint.CsharpNames.Namespace}{endpoint.CsharpNames.MethodName}";
var paths = !endpoint.Url.Paths.Any() ? endpoint.Url.AllPaths : endpoint.Url.Paths;
<text>
internal static readonly ApiUrls @(Raw(propertyName)) = new(new [] {@Raw(string.Join(", ", paths.Select(p=>$"\"{p.Path.TrimStart('/')}\"")))});
internal static readonly ApiUrls @(Raw(propertyName)) = new([@Raw(string.Join(", ", paths.Select(p=>$"\"{p.Path.TrimStart('/')}\"")))]);
</text>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<text>/// @Raw("<remarks>Note: " + Model.Stability + " within the OpenSearch server, " + warningMessage + "</remarks>")

</text>}
public partial class @Raw(Model.Name) @Raw(string.Format(": PlainRequestBase<{0}>, {1}", Model.CsharpNames.ParametersName, Model.InterfaceName))
{
public partial class @Raw(Model.Name) @Raw($": PlainRequestBase<{Model.CsharpNames.ParametersName}>, {Model.InterfaceName}")
{
protected @Raw(Model.InterfaceName) Self => this;
internal override ApiUrls ApiUrls => @apiLookup;
@foreach (var c in Model.Constructors)
Expand All @@ -34,10 +34,10 @@
</text>
}
// values part of the url path
@foreach (var part in Model.Parts)
@foreach (var part in Model.Parts.OrderBy(p => p.Name))
{
<text> [IgnoreDataMember]
@(Raw(part.HighLevelTypeName)) @(Raw(Model.InterfaceName)).@(part.InterfaceName) => Self.RouteValues.Get@(Raw(string.Format("<{0}>", part.HighLevelTypeName)))("@(part.Name)");
@(Raw(part.HighLevelTypeName)) @(Raw(Model.InterfaceName)).@(part.InterfaceName) => Self.RouteValues.Get@(Raw($"<{part.HighLevelTypeName}>"))("@(part.Name)");
</text>
}

Expand Down Expand Up @@ -69,7 +69,7 @@
}
@if (Model.NeedsGenericImplementation)
{<text>
public partial class @Raw(Model.CsharpNames.GenericRequestName) @Raw(string.Format(": {0}, {1}", Model.CsharpNames.RequestName, Model.CsharpNames.GenericInterfaceName))
public partial class @Raw(Model.CsharpNames.GenericRequestName) @Raw($": {Model.CsharpNames.RequestName}, {Model.CsharpNames.GenericInterfaceName}")
{
protected @Raw(Model.CsharpNames.GenericInterfaceName) TypedSelf => this;
@foreach (Constructor c in Model.GenericConstructors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
var name = Model.CsharpNames.RequestInterfaceName;
}
[InterfaceDataContract]
public partial interface @Raw(Model.Name) : IRequest@(Raw(string.Format("<{0}>", Model.CsharpNames.ParametersName)))
{
@foreach (var part in Model.UrlParts)
public partial interface @Raw(Model.Name) : IRequest@(Raw($"<{Model.CsharpNames.ParametersName}>"))
{
@foreach (var part in Model.UrlParts.OrderBy(p => p.Name))
{
<text> [IgnoreDataMember]
@(Raw(part.HighLevelTypeName)) @(part.InterfaceName) { get; }
Expand Down
35 changes: 0 additions & 35 deletions src/OpenSearch.Client/ApiUrlsLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,43 +61,8 @@ internal static partial class ApiUrlsLookups
internal static ApiUrls NoNamespaceGetScript = new ApiUrls(new[]{"_scripts/{id}"});
internal static ApiUrls NoNamespaceSource = new ApiUrls(new[]{"{index}/_source/{id}"});
internal static ApiUrls NoNamespaceIndex = new ApiUrls(new[]{"{index}/_doc/{id}", "{index}/_doc"});
internal static ApiUrls IndicesAddBlock = new ApiUrls(new[]{"{index}/_block/{block}"});
internal static ApiUrls IndicesAnalyze = new ApiUrls(new[]{"_analyze", "{index}/_analyze"});
internal static ApiUrls IndicesClearCache = new ApiUrls(new[]{"_cache/clear", "{index}/_cache/clear"});
internal static ApiUrls IndicesClone = new ApiUrls(new[]{"{index}/_clone/{target}"});
internal static ApiUrls IndicesClose = new ApiUrls(new[]{"{index}/_close"});
internal static ApiUrls IndicesCreate = new ApiUrls(new[]{"{index}"});
internal static ApiUrls IndicesDelete = new ApiUrls(new[]{"{index}"});
internal static ApiUrls IndicesDeleteAlias = new ApiUrls(new[]{"{index}/_alias/{name}"});
internal static ApiUrls IndicesDeleteTemplate = new ApiUrls(new[]{"_template/{name}"});
internal static ApiUrls IndicesExists = new ApiUrls(new[]{"{index}"});
internal static ApiUrls IndicesAliasExists = new ApiUrls(new[]{"_alias/{name}", "{index}/_alias/{name}"});
internal static ApiUrls IndicesTemplateExists = new ApiUrls(new[]{"_template/{name}"});
///<remarks>Deprecated as of OpenSearch 2.0</remarks>
internal static ApiUrls IndicesTypeExists = new ApiUrls(new[]{"{index}/_mapping/{type}"});
internal static ApiUrls IndicesFlush = new ApiUrls(new[]{"_flush", "{index}/_flush"});
internal static ApiUrls IndicesForceMerge = new ApiUrls(new[]{"_forcemerge", "{index}/_forcemerge"});
internal static ApiUrls IndicesGet = new ApiUrls(new[]{"{index}"});
internal static ApiUrls IndicesGetAlias = new ApiUrls(new[]{"_alias", "_alias/{name}", "{index}/_alias/{name}", "{index}/_alias"});
internal static ApiUrls IndicesGetFieldMapping = new ApiUrls(new[]{"_mapping/field/{fields}", "{index}/_mapping/field/{fields}"});
internal static ApiUrls IndicesGetMapping = new ApiUrls(new[]{"_mapping", "{index}/_mapping"});
internal static ApiUrls IndicesGetSettings = new ApiUrls(new[]{"_settings", "{index}/_settings", "{index}/_settings/{name}", "_settings/{name}"});
internal static ApiUrls IndicesGetTemplate = new ApiUrls(new[]{"_template", "_template/{name}"});
internal static ApiUrls IndicesOpen = new ApiUrls(new[]{"{index}/_open"});
internal static ApiUrls IndicesPutAlias = new ApiUrls(new[]{"{index}/_alias/{name}"});
internal static ApiUrls IndicesPutMapping = new ApiUrls(new[]{"{index}/_mapping"});
internal static ApiUrls IndicesUpdateSettings = new ApiUrls(new[]{"_settings", "{index}/_settings"});
internal static ApiUrls IndicesPutTemplate = new ApiUrls(new[]{"_template/{name}"});
internal static ApiUrls IndicesRecoveryStatus = new ApiUrls(new[]{"_recovery", "{index}/_recovery"});
internal static ApiUrls IndicesRefresh = new ApiUrls(new[]{"_refresh", "{index}/_refresh"});
internal static ApiUrls IndicesResolve = new ApiUrls(new[]{"_resolve/index/{name}"});
internal static ApiUrls IndicesRollover = new ApiUrls(new[]{"{alias}/_rollover", "{alias}/_rollover/{new_index}"});
internal static ApiUrls IndicesSegments = new ApiUrls(new[]{"_segments", "{index}/_segments"});
internal static ApiUrls IndicesShardStores = new ApiUrls(new[]{"_shard_stores", "{index}/_shard_stores"});
internal static ApiUrls IndicesShrink = new ApiUrls(new[]{"{index}/_shrink/{target}"});
internal static ApiUrls IndicesSplit = new ApiUrls(new[]{"{index}/_split/{target}"});
internal static ApiUrls IndicesBulkAlias = new ApiUrls(new[]{"_aliases"});
internal static ApiUrls IndicesValidateQuery = new ApiUrls(new[]{"_validate/query", "{index}/_validate/query"});
internal static ApiUrls NoNamespaceRootNodeInfo = new ApiUrls(new[]{""});
internal static ApiUrls NoNamespaceMultiGet = new ApiUrls(new[]{"_mget", "{index}/_mget"});
internal static ApiUrls NoNamespaceMultiSearch = new ApiUrls(new[]{"_msearch", "{index}/_msearch"});
Expand Down
Loading
Loading