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

Bump 7.x to 7.5 #4233

Merged
merged 11 commits into from
Nov 20, 2019
29 changes: 27 additions & 2 deletions src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,35 @@ public static class CodeConfiguration
"ml.set_upgrade_mode.json",
"ml.find_file_structure.json",
"monitoring.bulk.json",
"ml.estimate_memory_usage.json"
"ml.estimate_memory_usage.json",

"ccr.pause_auto_follow_pattern.json",
"ccr.resume_auto_follow_pattern.json",
"data_frame_transform_deprecated.delete_transform.json",
"data_frame_transform_deprecated.get_transform.json",
"data_frame_transform_deprecated.get_transform_stats.json",
"data_frame_transform_deprecated.preview_transform.json",
"data_frame_transform_deprecated.put_transform.json",
"data_frame_transform_deprecated.start_transform.json",
"data_frame_transform_deprecated.stop_transform.json",
"data_frame_transform_deprecated.update_transform.json",
"enrich.delete_policy.json",
"enrich.execute_policy.json",
"enrich.get_policy.json",
"enrich.put_policy.json",
"enrich.stats.json",
"slm.execute_retention.json",
"slm.get_stats.json",
"transform.delete_transform.json",
"transform.get_transform.json",
"transform.get_transform_stats.json",
"transform.preview_transform.json",
"transform.put_transform.json",
"transform.start_transform.json",
"transform.stop_transform.json",
"transform.update_transform.json",
};


/// <summary>
/// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
/// The class name minus Request is used as the canonical .NET name for the API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ namespace ApiGenerator.Configuration.Overrides
{
public class GlobalOverrides : EndpointOverridesBase
{
public IDictionary<string, Dictionary<string, string>> ObsoleteEnumMembers { get; set; } = new Dictionary<string, Dictionary<string, string>>();
public IDictionary<string, Dictionary<string, string>> ObsoleteEnumMembers { get; set; } = new Dictionary<string, Dictionary<string, string>>()
{
{ "VersionType", new Dictionary<string, string>() { { "force", "Force is no longer accepted by the server as of 7.5.0 and will result in an error when used" } } }
};

public override IDictionary<string, string> ObsoleteQueryStringParams { get; set; } = new Dictionary<string, string>
{
Expand Down Expand Up @@ -39,7 +42,9 @@ public class GlobalOverrides : EndpointOverridesBase
"parent", //can be removed once https://github.com/elastic/elasticsearch/pull/41098 is in
"copy_settings", //this still needs a PR?
"source", // allows the body to be specified as a request param, we do not want to advertise this with a strongly typed method
"timestamp"
"timestamp",
"time",
"bytes"
};
}
}
32 changes: 24 additions & 8 deletions src/CodeGeneration/ApiGenerator/Domain/RestApiSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.Linq;
using ApiGenerator.Domain.Specification;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace ApiGenerator.Domain
{
Expand Down Expand Up @@ -48,26 +49,41 @@ string CreateName(string name, string methodName, string @namespace)
}

var urlParameterEnums = (
from e in Endpoints.Values
from para in e.Url.Params.Values
where para.Options != null && para.Options.Any()
from e in Endpoints.Values
from para in e.Url.Params.Values
where para.Options != null && para.Options.Any()
let name = CreateName(para.ClsName, e.CsharpNames.MethodName, e.CsharpNames.Namespace)
where name != "Time"
select new EnumDescription
{
Name = CreateName(para.ClsName, e.CsharpNames.MethodName, e.CsharpNames.Namespace),
Name = name,
Options = para.Options
}).ToList();

var urlPartEnums = (
from e in Endpoints.Values
from part in e.Url.Parts
where part.Options != null && part.Options.Any()
from e in Endpoints.Values
from part in e.Url.Parts
where part.Options != null && part.Options.Any()
select new EnumDescription
{
Name = CreateName(part.Name.ToPascalCase(), e.CsharpNames.MethodName, e.CsharpNames.Namespace),
Options = part.Options
}).ToList();

_enumDescriptions = urlPartEnums.Concat(urlParameterEnums).DistinctBy(e => e.Name).ToList();
_enumDescriptions = urlPartEnums
.Concat(urlParameterEnums)
.DistinctBy(e => e.Name)
.ToList();

//TODO can be removed in 8.x
var versionType = _enumDescriptions.FirstOrDefault(f => f.Name == "VersionType");
if (versionType != null)
{
var options = new List<string>(versionType.Options);
options.Add("force");
versionType.Options = options;
}

return _enumDescriptions;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public IReadOnlyCollection<UrlPath> PathsWithDeprecations


public IReadOnlyCollection<UrlPart> Parts => Paths.SelectMany(p => p.Parts).DistinctBy(p => p.Name).ToList();

public bool IsPartless => !Parts.Any();

private static readonly string[] DocumentApiParts = { "index", "id" };

public bool IsDocumentApi => IsADocumentRoute(Parts);

public static bool IsADocumentRoute(IReadOnlyCollection<UrlPart> parts) =>
parts.Count() == DocumentApiParts.Length
&& parts.All(p => DocumentApiParts.Contains(p.Name));
Expand Down
10 changes: 10 additions & 0 deletions src/CodeGeneration/ApiGenerator/Generator/ApiEndpointFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ private static void PatchOfficialSpec(JObject original, string jsonFile)

if (pathsOverride != null) original.SelectToken("*.url.paths").Replace(pathsOverride);

var paramsOverride = patchedJson.SelectToken("*.params");

var originalParams = original.SelectToken("*.url.params") as JObject;
originalParams?.Merge(paramsOverride, new JsonMergeSettings
{
MergeArrayHandling = MergeArrayHandling.Union
});

if (paramsOverride != null) originalParams?.Replace(originalParams);

void ReplaceOptions(string path)
{
var optionsOverrides = patchedJson.SelectToken(path);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"description": "Parameters that are accepted by all API endpoints.",
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html",
"documentation" : {
"description": "Parameters that are accepted by all API endpoints.",
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html"
},
"params": {
"pretty": {
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
},
"h":{
"type":"list",
"description":"Comma-separated list of column names to display"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
"type":"string",
"description":"a short version of the Accept header, e.g. json, yaml"
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
},
"h":{
"type":"list",
"description":"Comma-separated list of column names to display"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
"pb"
]
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
},
"h":{
"type":"list",
"description":"Comma-separated list of column names to display"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
"type":"string",
"description":"a short version of the Accept header, e.g. json, yaml"
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
},
"h":{
"type":"list",
"description":"Comma-separated list of column names to display"
Expand All @@ -41,6 +33,19 @@
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"time":{
"type":"enum",
"description":"The unit in which to display time values",
"options":[
"d (Days)",
"h (Hours)",
"m (Minutes)",
"s (Seconds)",
"ms (Milliseconds)",
"micros (Microseconds)",
"nanos (Nanoseconds)"
]
},
"ts":{
"type":"boolean",
"description":"Set to false to disable timestamping",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"time":{
"type":"enum",
"description":"The unit in which to display time values",
"options":[
"d (Days)",
"h (Hours)",
"m (Minutes)",
"s (Seconds)",
"ms (Milliseconds)",
"micros (Microseconds)",
"nanos (Nanoseconds)"
]
},
"v":{
"type":"boolean",
"description":"Verbose mode. Display column headers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@
]
},
"params":{
"bytes":{
"type":"enum",
"description":"The unit in which to display byte values",
"options":[
"b",
"k",
"kb",
"m",
"mb",
"g",
"gb",
"t",
"tb",
"p",
"pb"
]
},
"format":{
"type":"string",
"description":"a short version of the Accept header, e.g. json, yaml"
Expand Down Expand Up @@ -45,6 +62,19 @@
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"time":{
"type":"enum",
"description":"The unit in which to display time values",
"options":[
"d (Days)",
"h (Hours)",
"m (Minutes)",
"s (Seconds)",
"ms (Milliseconds)",
"micros (Microseconds)",
"nanos (Nanoseconds)"
]
},
"v":{
"type":"boolean",
"description":"Verbose mode. Display column headers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"time":{
"type":"enum",
"description":"The unit in which to display time values",
"options":[
"d (Days)",
"h (Hours)",
"m (Minutes)",
"s (Seconds)",
"ms (Milliseconds)",
"micros (Microseconds)",
"nanos (Nanoseconds)"
]
},
"v":{
"type":"boolean",
"description":"Verbose mode. Display column headers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"parts":{
"index":{
"type":"list",
"description":"A comma-separated list of index names to limit the returned information"
"description":"Comma-separated list or wildcard expression of index names to limit the returned information"
}
}
}
Expand All @@ -32,6 +32,11 @@
"type":"string",
"description":"a short version of the Accept header, e.g. json, yaml"
},
"active_only":{
"type":"boolean",
"description":"If `true`, the response only includes ongoing shard recoveries",
"default":false
},
"bytes":{
"type":"enum",
"description":"The unit in which to display byte values",
Expand All @@ -49,9 +54,10 @@
"pb"
]
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
"detailed":{
"type":"boolean",
"description":"If `true`, the response includes detailed information about shard recoveries",
"default":false
},
"h":{
"type":"list",
Expand All @@ -62,10 +68,27 @@
"description":"Return help information",
"default":false
},
"index":{
"type":"list",
"description":"Comma-separated list or wildcard expression of index names to limit the returned information"
},
"s":{
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"time":{
"type":"enum",
"description":"The unit in which to display time values",
"options":[
"d (Days)",
"h (Hours)",
"m (Minutes)",
"s (Seconds)",
"ms (Milliseconds)",
"micros (Microseconds)",
"nanos (Nanoseconds)"
]
},
"v":{
"type":"boolean",
"description":"Verbose mode. Display column headers",
Expand Down
Loading