Skip to content

Commit 3b727c9

Browse files
authored
5.4 feature branch (#2754)
* Updated api gen to 5.4 and added a way to patch specification files through special *.patch.json companion files. Due to pending discusion on elastic/elasticsearch@e579629 :q! * updated x-pack spec to 5.4 * add codegen part for xpack info related APIs * Added support for Field Caps API * add support for RemoteInfo API and adds cross cluster support to IndexName * added support for SourceExists() * add skipversion, eventhough this API existed it was undocumented prior to 5.4 * expose word delimiter graph token filter as per elastic/elasticsearch#23327 * spaces=>tabs * expose num_reduce_phases as per elastic/elasticsearch#23288 * implemented XPackInfo() started on XPackUsage() * added response structure for XPackUsage() * change license date from DateTime to DateTimeOffset' * implement PR feedback on #2743 * remove explicit folder includes in csproj files
1 parent 07d2c41 commit 3b727c9

File tree

75 files changed

+3801
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3801
-439
lines changed

src/CodeGeneration/ApiGenerator/ApiGenerator.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private static RestApiSpec CreateRestApiSpecModel(string downloadBranch, string[
5858
{
5959
if (file.EndsWith("_common.json")) RestApiSpec.CommonApiQueryParameters = CreateCommonApiQueryParameters(file);
6060
else if (file.EndsWith(".obsolete.json")) continue;
61+
else if (file.EndsWith(".patch.json")) continue;
6162
else
6263
{
6364
var endpoint = CreateApiEndpoint(file);
@@ -83,14 +84,29 @@ public static string PascalCase(string s)
8384

8485
private static KeyValuePair<string, ApiEndpoint> CreateApiEndpoint(string jsonFile)
8586
{
86-
var json = File.ReadAllText(jsonFile);
87-
var endpoint = JsonConvert.DeserializeObject<Dictionary<string, ApiEndpoint>>(json).First();
87+
var officialJsonSpec = JObject.Parse(File.ReadAllText(jsonFile));
88+
PatchOfficialSpec(officialJsonSpec, jsonFile);
89+
var endpoint = officialJsonSpec.ToObject<Dictionary<string, ApiEndpoint>>().First();
8890
endpoint.Value.CsharpMethodName = CreateMethodName(endpoint.Key);
89-
PatchObsoleteValues(jsonFile, endpoint.Value);
91+
AddObsoletes(jsonFile, endpoint.Value);
9092
return endpoint;
9193
}
9294

93-
private static void PatchObsoleteValues(string jsonFile, ApiEndpoint endpoint)
95+
private static void PatchOfficialSpec(JObject original, string jsonFile)
96+
{
97+
var directory = Path.GetDirectoryName(jsonFile);
98+
var patchFile = Path.Combine(directory, Path.GetFileNameWithoutExtension(jsonFile)) + ".patch.json";
99+
if (!File.Exists(patchFile)) return;
100+
101+
var patchedJson = JObject.Parse(File.ReadAllText(patchFile));
102+
103+
original.Merge(patchedJson, new JsonMergeSettings
104+
{
105+
MergeArrayHandling = MergeArrayHandling.Union
106+
});
107+
}
108+
109+
private static void AddObsoletes(string jsonFile, ApiEndpoint endpoint)
94110
{
95111
var directory = Path.GetDirectoryName(jsonFile);
96112
var obsoleteFile = Path.Combine(directory, Path.GetFileNameWithoutExtension(jsonFile)) + ".obsolete.json";
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<TargetFramework>net46</TargetFramework>
55
<VersionPrefix>6.0.0</VersionPrefix>
66
<VersionSuffix>alpha</VersionSuffix>
77
</PropertyGroup>
88
<ItemGroup>
9-
<ProjectReference Include="..\..\Nest\Nest.csproj" />
9+
<!--<ProjectReference Include="..\..\Nest\Nest.csproj" />-->
1010
<PackageReference Include="Newtonsoft.Json" Version="10.0.1" />
1111
<PackageReference Include="RazorMachine" Version="2.6.1" />
1212
<!-- TODO the following packages prevent us to jump to netcoreapp1.0 -->
1313
<PackageReference Include="CsQuery" Version="1.3.4" />
1414
<PackageReference Include="ShellProgressBar" Version="3.0.0" />
1515
</ItemGroup>
16-
</Project>
16+
<ItemGroup>
17+
<Folder Include="RestSpecification\XPack\Info" />
18+
</ItemGroup>
19+
</Project>

src/CodeGeneration/ApiGenerator/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void Main(string[] args)
4343
if (redownloadCoreSpecification)
4444
RestSpecDownloader.Download(downloadBranch);
4545

46-
ApiGenerator.Generate(downloadBranch, "Core", "Graph", "License", "Security", "Watcher");
46+
ApiGenerator.Generate(downloadBranch, "Core", "Graph", "License", "Security", "Watcher", "Info");
4747

4848
//ApiGenerator.Generate(); //generates everything under ApiSpecification
4949
}

src/CodeGeneration/ApiGenerator/RestSpecification/Core/exists.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
}
2424
},
2525
"params": {
26+
"stored_fields": {
27+
"type": "list",
28+
"description" : "A comma-separated list of stored fields to return in the response"
29+
},
2630
"parent": {
2731
"type" : "string",
2832
"description" : "The ID of the parent document"
@@ -42,6 +46,27 @@
4246
"routing": {
4347
"type" : "string",
4448
"description" : "Specific routing value"
49+
},
50+
"_source": {
51+
"type" : "list",
52+
"description" : "True or false to return the _source field or not, or a list of fields to return"
53+
},
54+
"_source_exclude": {
55+
"type" : "list",
56+
"description" : "A list of fields to exclude from the returned _source field"
57+
},
58+
"_source_include": {
59+
"type" : "list",
60+
"description" : "A list of fields to extract and return from the _source field"
61+
},
62+
"version" : {
63+
"type" : "number",
64+
"description" : "Explicit version number for concurrency control"
65+
},
66+
"version_type": {
67+
"type" : "enum",
68+
"options" : ["internal", "external", "external_gte", "force"],
69+
"description" : "Specific version type"
4570
}
4671
}
4772
},
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"exists_source": {
3+
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html",
4+
"methods": ["HEAD"],
5+
"url": {
6+
"path": "/{index}/{type}/{id}/_source",
7+
"paths": ["/{index}/{type}/{id}/_source"],
8+
"parts": {
9+
"id": {
10+
"type" : "string",
11+
"required" : true,
12+
"description" : "The document ID"
13+
},
14+
"index": {
15+
"type" : "string",
16+
"required" : true,
17+
"description" : "The name of the index"
18+
},
19+
"type": {
20+
"type" : "string",
21+
"required" : true,
22+
"description" : "The type of the document; use `_all` to fetch the first document matching the ID across all types"
23+
}
24+
},
25+
"params": {
26+
"parent": {
27+
"type" : "string",
28+
"description" : "The ID of the parent document"
29+
},
30+
"preference": {
31+
"type" : "string",
32+
"description" : "Specify the node or shard the operation should be performed on (default: random)"
33+
},
34+
"realtime": {
35+
"type" : "boolean",
36+
"description" : "Specify whether to perform the operation in realtime or search mode"
37+
},
38+
"refresh": {
39+
"type" : "boolean",
40+
"description" : "Refresh the shard containing the document before performing the operation"
41+
},
42+
"routing": {
43+
"type" : "string",
44+
"description" : "Specific routing value"
45+
},
46+
"_source": {
47+
"type" : "list",
48+
"description" : "True or false to return the _source field or not, or a list of fields to return"
49+
},
50+
"_source_exclude": {
51+
"type" : "list",
52+
"description" : "A list of fields to exclude from the returned _source field"
53+
},
54+
"_source_include": {
55+
"type" : "list",
56+
"description" : "A list of fields to extract and return from the _source field"
57+
},
58+
"version" : {
59+
"type" : "number",
60+
"description" : "Explicit version number for concurrency control"
61+
},
62+
"version_type": {
63+
"type" : "enum",
64+
"options" : ["internal", "external", "external_gte", "force"],
65+
"description" : "Specific version type"
66+
}
67+
}
68+
},
69+
"body": null
70+
}
71+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"field_caps": {
3+
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html",
4+
"methods": ["GET", "POST"],
5+
"url": {
6+
"path": "/_field_caps",
7+
"paths": [
8+
"/_field_caps",
9+
"/{index}/_field_caps"
10+
],
11+
"parts": {
12+
"index": {
13+
"type" : "list",
14+
"description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices"
15+
}
16+
},
17+
"params": {
18+
"fields": {
19+
"type" : "list",
20+
"description" : "A comma-separated list of field names"
21+
},
22+
"ignore_unavailable": {
23+
"type" : "boolean",
24+
"description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)"
25+
},
26+
"allow_no_indices": {
27+
"type" : "boolean",
28+
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
29+
},
30+
"expand_wildcards": {
31+
"type" : "enum",
32+
"options" : ["open","closed","none","all"],
33+
"default" : "open",
34+
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
35+
}
36+
}
37+
},
38+
"body": {
39+
"description": "Field json objects containing an array of field names",
40+
"required": false
41+
}
42+
}
43+
}

src/CodeGeneration/ApiGenerator/RestSpecification/Core/indices.clear_cache.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
"type" : "boolean",
5151
"description" : "Clear the recycler cache"
5252
},
53+
"request_cache": {
54+
"type" : "boolean",
55+
"description" : "Clear request cache"
56+
},
5357
"request": {
5458
"type" : "boolean",
5559
"description" : "Clear request cache"

src/CodeGeneration/ApiGenerator/RestSpecification/Core/indices.exists.json

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
{
22
"indices.exists": {
3-
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html",
4-
"methods": ["HEAD"],
3+
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html",
4+
"methods": [ "HEAD" ],
55
"url": {
66
"path": "/{index}",
7-
"paths": ["/{index}"],
7+
"paths": [ "/{index}" ],
88
"parts": {
99
"index": {
10-
"type" : "list",
11-
"required" : true,
12-
"description" : "A comma-separated list of indices to check"
10+
"type": "list",
11+
"required": true,
12+
"description": "A comma-separated list of index names"
1313
}
1414
},
1515
"params": {
16+
"local": {
17+
"type": "boolean",
18+
"description": "Return local information, do not retrieve the state from master node (default: false)"
19+
},
1620
"ignore_unavailable": {
17-
"type" : "boolean",
18-
"description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)"
21+
"type": "boolean",
22+
"description": "Ignore unavailable indexes (default: false)"
1923
},
2024
"allow_no_indices": {
21-
"type" : "boolean",
22-
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
25+
"type": "boolean",
26+
"description": "Ignore if a wildcard expression resolves to no concrete indices (default: false)"
2327
},
2428
"expand_wildcards": {
25-
"type" : "enum",
26-
"options" : ["open","closed","none","all"],
27-
"default" : "open",
28-
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
29+
"type": "enum",
30+
"options": [ "open", "closed", "none", "all" ],
31+
"default": "open",
32+
"description": "Whether wildcard expressions should get expanded to open or closed indices (default: open)"
2933
},
30-
"local": {
31-
"type": "boolean",
32-
"description": "Return local information, do not retrieve the state from master node (default: false)"
34+
"flat_settings": {
35+
"type": "boolean",
36+
"description": "Return settings in flat format (default: false)"
37+
},
38+
"include_defaults": {
39+
"type": "boolean",
40+
"description": "Whether to return all default setting for each of the indices.",
41+
"default": false
3342
}
3443
}
3544
},

src/CodeGeneration/ApiGenerator/RestSpecification/Core/indices.exists_alias.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"methods": ["HEAD"],
55
"url": {
66
"path": "/_alias/{name}",
7-
"paths": ["/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"],
7+
"paths": ["/_alias/{name}", "/{index}/_alias/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "list",
@@ -17,22 +17,22 @@
1717
},
1818
"params": {
1919
"ignore_unavailable": {
20-
"type" : "boolean",
21-
"description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)"
20+
"type" : "boolean",
21+
"description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)"
2222
},
2323
"allow_no_indices": {
24-
"type" : "boolean",
25-
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
24+
"type" : "boolean",
25+
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
2626
},
2727
"expand_wildcards": {
28-
"type" : "enum",
29-
"options" : ["open","closed","none","all"],
30-
"default" : ["open", "closed"],
31-
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
28+
"type" : "enum",
29+
"options" : ["open","closed","none","all"],
30+
"default" : "all",
31+
"description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both."
3232
},
3333
"local": {
34-
"type": "boolean",
35-
"description": "Return local information, do not retrieve the state from master node (default: false)"
34+
"type": "boolean",
35+
"description": "Return local information, do not retrieve the state from master node (default: false)"
3636
}
3737
}
3838
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"indices.exists_alias": {
3+
"url": {
4+
"paths": ["/{index}/_alias"]
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)