Skip to content

Update API REST specs to 7.2.0 #3979

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 4 commits into from
Aug 1, 2019
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ public static class CodeConfiguration

// these APIs are not ready for primetime yet
"rank_eval.json",
"data_frame.delete_data_frame_transform.json",
"data_frame.get_data_frame_transform.json",
"data_frame.get_data_frame_transform_stats.json",
"data_frame.preview_data_frame_transform.json",
"data_frame.put_data_frame_transform.json",
"data_frame.start_data_frame_transform.json",
"data_frame.stop_data_frame_transform.json",

"scripts_painless_context.json",

// these APIs are new and need to be mapped
"ml.set_upgrade_mode.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
using ApiGenerator.Configuration;
using ApiGenerator.Domain.Specification;

namespace ApiGenerator.Domain.Code.HighLevel.Requests
namespace ApiGenerator.Domain.Code.HighLevel.Requests
{
public class RequestPartialImplementation
{
public CsharpNames CsharpNames { get; set; }
public string OfficialDocumentationLink { get; set; }
public Stability Stability { get; set; }
public IReadOnlyCollection<UrlPart> Parts { get; set; }
public IReadOnlyCollection<UrlPath> Paths { get; set; }
public IReadOnlyCollection<QueryParameters> Params { get; set; }
Expand All @@ -20,7 +21,7 @@ public class RequestPartialImplementation
public bool NeedsGenericImplementation => !GenerateOnlyGenericInterface && !string.IsNullOrWhiteSpace(CsharpNames.GenericsDeclaredOnRequest);

public string Name => CsharpNames.GenericOrNonGenericRequestPreference;

public string InterfaceName => CsharpNames.GenericOrNonGenericInterfacePreference;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class LowLevelClientMethod

public string Arguments { get; set; }
public string OfficialDocumentationLink { get; set; }

public Stability Stability { get; set; }
public string PerPathMethodName { get; set; }
public string HttpMethod { get; set; }

Expand Down
39 changes: 23 additions & 16 deletions src/CodeGeneration/ApiGenerator/Domain/Specification/ApiEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,41 @@
using ApiGenerator.Domain.Code.HighLevel.Requests;
using ApiGenerator.Domain.Code.LowLevel;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace ApiGenerator.Domain.Specification
{
public class ApiEndpoint
{
/// <summary> The filename of the spec describing the api endpoint </summary>
public string FileName { get; set; }

/// <summary> The original name as declared in the spec </summary>
public string Name { get; set; }

/// <summary> The original namespace as declared in the spec </summary>
public string Namespace { get; set; }

/// <summary> The original method name as declared in the spec </summary>
public string MethodName { get; set; }

/// <summary> Computed Csharp identifier names </summary>
public CsharpNames CsharpNames { get; set; }

public CsharpNames CsharpNames { get; set; }

[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("stability")]
public Stability Stability { get; set; }

[JsonProperty("documentation")]
public string OfficialDocumentationLink { get; set; }

public UrlInformation Url { get; set; }

public Body Body { get; set; }

[JsonProperty("methods")]
public IReadOnlyCollection<string> HttpMethods { get; set; }

public IEndpointOverrides Overrides { get; internal set; }

public RequestInterface RequestInterface => new RequestInterface
Expand All @@ -45,30 +50,31 @@ public class ApiEndpoint
PartialParameters = Body == null ? Enumerable.Empty<QueryParameters>().ToList() : Url.Params.Values.Where(p=>p.RenderPartial && !p.Skip).ToList(),
OfficialDocumentationLink = OfficialDocumentationLink
};

public RequestPartialImplementation RequestPartialImplementation => new RequestPartialImplementation
{
CsharpNames = CsharpNames,
OfficialDocumentationLink = OfficialDocumentationLink,
Stability = Stability,
Paths = Url.Paths,
Parts = Url.Parts,
Params = Url.Params.Values.Where(p=>!p.Skip).ToList(),
Constructors = Constructor.RequestConstructors(CsharpNames, Url, inheritsFromPlainRequestBase: true).ToList(),
GenericConstructors = Constructor.RequestConstructors(CsharpNames, Url, inheritsFromPlainRequestBase: false).ToList(),
HasBody = Body != null,
};

public DescriptorPartialImplementation DescriptorPartialImplementation => new DescriptorPartialImplementation
{
CsharpNames = CsharpNames,
CsharpNames = CsharpNames,
OfficialDocumentationLink = OfficialDocumentationLink,
Constructors = Constructor.DescriptorConstructors(CsharpNames, Url).ToList(),
Paths = Url.Paths,
Parts = Url.Parts,
Params = Url.Params.Values.Where(p=>!p.Skip).ToList(),
HasBody = Body != null,
};

public RequestParameterImplementation RequestParameterImplementation => new RequestParameterImplementation
{
CsharpNames = CsharpNames,
Expand All @@ -89,7 +95,7 @@ public string PreferredHttpMethod
}

public string HighLevelMethodXmlDocDescription => $"<c>{PreferredHttpMethod}</c> request to the <c>{Name}</c> API, read more about this API online:";

public HighLevelModel HighLevelModel => new HighLevelModel
{
CsharpNames = CsharpNames,
Expand Down Expand Up @@ -132,15 +138,16 @@ public IReadOnlyCollection<LowLevelClientMethod> LowLevelClientMethods
.Select(p => p.Argument)
.Concat(new[] { CsharpNames.ParametersName + " requestParameters = null" })
.ToList();

var apiMethod = new LowLevelClientMethod
{
Arguments = string.Join(", ", args),
CsharpNames = CsharpNames,
PerPathMethodName = methodName,
HttpMethod = httpMethod,
OfficialDocumentationLink = OfficialDocumentationLink,
DeprecatedPath = path.Deprecation,
Stability = Stability,
DeprecatedPath = path.Deprecation,
Path = path.Path,
Parts = parts,
Url = Url,
Expand Down
25 changes: 25 additions & 0 deletions src/CodeGeneration/ApiGenerator/Domain/Specification/Stability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Runtime.Serialization;

namespace ApiGenerator.Domain.Specification
{
public enum Stability
{
/// <summary>
/// Highly likely to break in the near future (minor/path), no BWC guarantees. Possibly removed in the future.
/// </summary>
[EnumMember(Value = "experimental")]
Experimental,

/// <summary>
/// Less likely to break or be removed but still reserve the right to do so.
/// </summary>
[EnumMember(Value = "beta")]
Beta,

/// <summary>
/// No backwards breaking changes in a minor.
/// </summary>
[EnumMember(Value = "stable")]
Stable
}
}
12 changes: 9 additions & 3 deletions src/CodeGeneration/ApiGenerator/Generator/ApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public static async Task Generate(string downloadBranch, params string[] folders
}
}

// Check if there are any non-Stable endpoints present.
foreach (var endpoint in spec.Endpoints)
{
if (endpoint.Value.Stability != Stability.Stable)
{
Warnings.Add($"Endpoint {endpoint.Value.Name} is not marked as Stable ({endpoint.Value.Stability})");
}
}

if (Warnings.Count == 0) return;

Console.ForegroundColor = ConsoleColor.Yellow;
Expand Down Expand Up @@ -106,7 +115,6 @@ private static RestApiSpec CreateRestApiSpecModel(string downloadBranch, string[
var isIgnored = CodeConfiguration.IgnoredApis.Contains($"{value}.json");
if (isIgnored) Warnings.Add($"{value} uses MapsApi: {key} ignored in ${nameof(CodeConfiguration)}.{nameof(CodeConfiguration.IgnoredApis)}");
else Warnings.Add($"{value} uses MapsApi: {key} which does not exist");

}

return new RestApiSpec { Endpoints = endpoints, Commit = downloadBranch };
Expand All @@ -119,7 +127,5 @@ private static SortedDictionary<string, QueryParameters> CreateCommonApiQueryPar
var commonParameters = jobject.Property("params").Value.ToObject<Dictionary<string, QueryParameters>>();
return ApiQueryParametersPatcher.Patch(null, commonParameters, null, false);
}


}
}
1 change: 0 additions & 1 deletion src/CodeGeneration/ApiGenerator/Generator/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void A(string s)
}
}


private static IEnumerable<string> RenderDocumentation(params string[] doc)
{
doc = (doc?.SelectMany(WrapDocumentation) ?? Enumerable.Empty<string>()).ToArray();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"bulk": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html",
"stability": "stable",
"methods": ["POST", "PUT"],
"url": {
"path": "/_bulk",
"paths": ["/_bulk", "/{index}/_bulk", "/{index}/{type}/_bulk"],
"parts": {
"index": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.aliases": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/aliases",
"paths": ["/_cat/aliases", "/_cat/aliases/{name}"],
"parts": {
"name": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.allocation": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/allocation",
"paths": ["/_cat/allocation", "/_cat/allocation/{node_id}"],
"parts": {
"node_id": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.count": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/count",
"paths": ["/_cat/count", "/_cat/count/{index}"],
"parts": {
"index": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.fielddata": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/fielddata",
"paths": ["/_cat/fielddata", "/_cat/fielddata/{fields}"],
"parts": {
"fields": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.health": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/health",
"paths": ["/_cat/health"],
"parts": {
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.help": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat",
"paths": ["/_cat"],
"parts": {
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.indices": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/indices",
"paths": ["/_cat/indices", "/_cat/indices/{index}"],
"parts": {
"index": {
Expand Down Expand Up @@ -57,6 +57,11 @@
"type": "boolean",
"description": "Verbose mode. Display column headers",
"default": false
},
"include_unloaded_segments": {
"type": "boolean",
"description": "If set to true segment stats will include stats for segments that are not currently loaded into memory",
"default": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.master": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/master",
"paths": ["/_cat/master"],
"parts": {
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.nodeattrs": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/nodeattrs",
"paths": ["/_cat/nodeattrs"],
"parts": {
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.nodes": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/nodes",
"paths": ["/_cat/nodes"],
"parts": {
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.pending_tasks": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/pending_tasks",
"paths": ["/_cat/pending_tasks"],
"parts": {
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.plugins": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/plugins",
"paths": ["/_cat/plugins"],
"params": {
"format": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cat.recovery": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html",
"stability": "stable",
"methods": ["GET"],
"url": {
"path": "/_cat/recovery",
"paths": ["/_cat/recovery", "/_cat/recovery/{index}"],
"parts": {
"index": {
Expand Down
Loading