Skip to content

Commit b27b6f4

Browse files
authored
update abstractions to deal with 8.0.0-SNAPSHOT changes (#4192)
* update abstractions to deal with 8.0.0-SNAPSHOT changes * Remove document type from client and tests * Use Path separator * update specs * update code from specs * update specs and removes type params from patch files * take fix from 7.x for flakey slm test
1 parent 8538521 commit b27b6f4

File tree

193 files changed

+5269
-6275
lines changed

Some content is hidden

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

193 files changed

+5269
-6275
lines changed

build/scripts/scripts.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<PackageReference Include="FSharp.Core" Version="4.7.0" />
3737

3838
<PackageReference Include="Bullseye" Version="3.0.0" />
39-
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20191017T152836" />
39+
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20191031T103739" />
4040

4141
<PackageReference Include="Fake.Core.Environment" Version="5.15.0" />
4242
<PackageReference Include="Fake.Core.SemVer" Version="5.15.0" />

src/CodeGeneration/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,37 @@ public static class CodeConfiguration
4343
"ml.set_upgrade_mode.json",
4444
"ml.find_file_structure.json",
4545
"monitoring.bulk.json",
46-
"ml.estimate_memory_usage.json"
46+
"ml.estimate_memory_usage.json",
47+
48+
"get_script_context.json",
49+
"indices.exists_type.json",
50+
"ccr.pause_auto_follow_pattern.json",
51+
"ccr.resume_auto_follow_pattern.json",
52+
"data_frame_transform_deprecated.delete_transform.json",
53+
"data_frame_transform_deprecated.get_transform.json",
54+
"data_frame_transform_deprecated.get_transform_stats.json",
55+
"data_frame_transform_deprecated.preview_transform.json",
56+
"data_frame_transform_deprecated.put_transform.json",
57+
"data_frame_transform_deprecated.start_transform.json",
58+
"data_frame_transform_deprecated.stop_transform.json",
59+
"data_frame_transform_deprecated.update_transform.json",
60+
"enrich.delete_policy.json",
61+
"enrich.execute_policy.json",
62+
"enrich.get_policy.json",
63+
"enrich.put_policy.json",
64+
"enrich.stats.json",
65+
"slm.execute_retention.json",
66+
"slm.get_stats.json",
67+
"transform.delete_transform.json",
68+
"transform.get_transform.json",
69+
"transform.get_transform_stats.json",
70+
"transform.preview_transform.json",
71+
"transform.put_transform.json",
72+
"transform.start_transform.json",
73+
"transform.stop_transform.json",
74+
"transform.update_transform.json",
4775
};
4876

49-
5077
/// <summary>
5178
/// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
5279
/// The class name minus Request is used as the canonical .NET name for the API.

src/CodeGeneration/ApiGenerator/Configuration/Overrides/GlobalOverrides.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public class GlobalOverrides : EndpointOverridesBase
3939
"parent", //can be removed once https://github.com/elastic/elasticsearch/pull/41098 is in
4040
"copy_settings", //this still needs a PR?
4141
"source", // allows the body to be specified as a request param, we do not want to advertise this with a strongly typed method
42-
"timestamp"
42+
"timestamp",
43+
"time"
4344
};
4445
}
4546
}

src/CodeGeneration/ApiGenerator/Domain/RestApiSpec.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.ObjectModel;
44
using System.Linq;
55
using ApiGenerator.Domain.Specification;
6+
using Microsoft.CodeAnalysis.CSharp.Syntax;
67

78
namespace ApiGenerator.Domain
89
{
@@ -17,7 +18,7 @@ public class RestApiSpec
1718
public string Commit { get; set; }
1819

1920
public static SortedDictionary<string, QueryParameters> CommonApiQueryParameters { get; set; }
20-
21+
2122
public IDictionary<string, ApiEndpoint> Endpoints { get; set; }
2223

2324
public ImmutableSortedDictionary<string, ReadOnlyCollection<ApiEndpoint>> EndpointsPerNamespace =>
@@ -48,26 +49,31 @@ string CreateName(string name, string methodName, string @namespace)
4849
}
4950

5051
var urlParameterEnums = (
51-
from e in Endpoints.Values
52-
from para in e.Url.Params.Values
53-
where para.Options != null && para.Options.Any()
52+
from e in Endpoints.Values
53+
from para in e.Url.Params.Values
54+
where para.Options != null && para.Options.Any()
55+
let name = CreateName(para.ClsName, e.CsharpNames.MethodName, e.CsharpNames.Namespace)
56+
where name != "Time"
5457
select new EnumDescription
5558
{
56-
Name = CreateName(para.ClsName, e.CsharpNames.MethodName, e.CsharpNames.Namespace),
59+
Name = name,
5760
Options = para.Options
5861
}).ToList();
59-
62+
6063
var urlPartEnums = (
61-
from e in Endpoints.Values
62-
from part in e.Url.Parts
63-
where part.Options != null && part.Options.Any()
64+
from e in Endpoints.Values
65+
from part in e.Url.Parts
66+
where part.Options != null && part.Options.Any()
6467
select new EnumDescription
6568
{
6669
Name = CreateName(part.Name.ToPascalCase(), e.CsharpNames.MethodName, e.CsharpNames.Namespace),
6770
Options = part.Options
6871
}).ToList();
6972

70-
_enumDescriptions = urlPartEnums.Concat(urlParameterEnums).DistinctBy(e => e.Name).ToList();
73+
_enumDescriptions = urlPartEnums
74+
.Concat(urlParameterEnums)
75+
.DistinctBy(e => e.Name)
76+
.ToList();
7177
return _enumDescriptions;
7278
}
7379
}

src/CodeGeneration/ApiGenerator/Domain/Specification/UrlInformation.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace ApiGenerator.Domain.Specification
1010
{
11-
11+
1212
// ReSharper disable once ClassNeverInstantiated.Global
1313
public class UrlInformation
1414
{
@@ -17,12 +17,12 @@ public class UrlInformation
1717
[JsonProperty("paths")]
1818
private IReadOnlyCollection<string> OriginalPaths { get; set; }
1919

20-
[JsonProperty("parts")]
20+
[JsonProperty("parts")]
2121
public IDictionary<string, UrlPart> OriginalParts { get; set; }
22-
22+
2323
[JsonProperty("deprecated_paths")]
2424
private IReadOnlyCollection<DeprecatedPath> DeprecatedPaths { get; set; }
25-
25+
2626
private List<UrlPath> _paths;
2727
public IReadOnlyCollection<UrlPath> Paths
2828
{
@@ -34,17 +34,18 @@ public IReadOnlyCollection<UrlPath> Paths
3434
return _paths;
3535
}
3636
}
37-
37+
3838
private List<UrlPath> _pathsWithDeprecation;
3939
public IReadOnlyCollection<UrlPath> PathsWithDeprecations
4040
{
4141
get
4242
{
4343
if (_pathsWithDeprecation != null && _pathsWithDeprecation.Count > 0) return _pathsWithDeprecation;
44-
44+
4545
var paths = Paths ?? new UrlPath[] {};
4646
if (DeprecatedPaths == null || DeprecatedPaths.Count == 0) return Paths;
47-
47+
if (OriginalParts == null) return Paths;
48+
4849
//some deprecated paths describe aliases to the canonical using the same path e.g
4950
// PUT /{index}/_mapping/{type}
5051
// PUT /{index}/{type}/_mappings
@@ -56,14 +57,14 @@ public IReadOnlyCollection<UrlPath> PathsWithDeprecations
5657
var withoutDeprecatedAliases = DeprecatedPaths
5758
.Select(deprecatedPath => new
5859
{
59-
deprecatedPath,
60+
deprecatedPath,
6061
parts = new HashSet<string>(OriginalParts.Keys.Where(k => deprecatedPath.Path.Contains($"{{{k}}}")))
6162
})
6263
.GroupBy(t => t.parts, HashSet<string>.CreateSetComparer())
6364
.Where(grouped => !canonicalPartNameLookup.Any(set => set.SetEquals(grouped.Key)))
64-
.Select(grouped => grouped.First().deprecatedPath);
65-
66-
65+
.Select(grouped => grouped.First().deprecatedPath);
66+
67+
6768
_pathsWithDeprecation = paths
6869
.Concat(withoutDeprecatedAliases.Select(p => new UrlPath(p, OriginalParts, Paths)))
6970
.ToList();
@@ -73,13 +74,13 @@ public IReadOnlyCollection<UrlPath> PathsWithDeprecations
7374

7475

7576
public IReadOnlyCollection<UrlPart> Parts => Paths.SelectMany(p => p.Parts).DistinctBy(p => p.Name).ToList();
76-
77+
7778
public bool IsPartless => !Parts.Any();
7879

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

8182
public bool IsDocumentApi => IsADocumentRoute(Parts);
82-
83+
8384
public static bool IsADocumentRoute(IReadOnlyCollection<UrlPart> parts) =>
8485
parts.Count() == DocumentApiParts.Length
8586
&& parts.All(p => DocumentApiParts.Contains(p.Name));

src/CodeGeneration/ApiGenerator/RestSpecDownloader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private void DownloadJsonDefinitions(Specification spec, IProgressBar pbar)
6060

6161
private void FindJsonFilesOnListing(Specification spec, string html, IProgressBar pbar)
6262
{
63-
if (!Directory.Exists(GeneratorLocations.RestSpecificationFolder))
63+
if (!Directory.Exists(GeneratorLocations.RestSpecificationFolder))
6464
Directory.CreateDirectory(GeneratorLocations.RestSpecificationFolder);
6565

6666
var dom = CQ.Create(html);
@@ -92,7 +92,7 @@ private void WriteToEndpointsFolder(string folder, string filename, string conte
9292
{
9393
var f = Path.Combine(GeneratorLocations.RestSpecificationFolder, folder);
9494
if (!Directory.Exists(f)) Directory.CreateDirectory(f);
95-
File.WriteAllText(f + "\\" + filename, contents);
95+
File.WriteAllText(f + Path.DirectorySeparatorChar + filename, contents);
9696
}
9797

9898
private class Specification

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2-
"description": "Parameters that are accepted by all API endpoints.",
3-
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html",
2+
"documentation" : {
3+
"description": "Parameters that are accepted by all API endpoints.",
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html"
5+
},
46
"params": {
57
"pretty": {
68
"type": "boolean",

src/CodeGeneration/ApiGenerator/RestSpecification/Core/cat.aliases.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
"type":"boolean",
3737
"description":"Return local information, do not retrieve the state from master node (default: false)"
3838
},
39-
"master_timeout":{
40-
"type":"time",
41-
"description":"Explicit operation timeout for connection to master node"
42-
},
4339
"h":{
4440
"type":"list",
4541
"description":"Comma-separated list of column names to display"

src/CodeGeneration/ApiGenerator/RestSpecification/Core/cat.count.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@
3232
"type":"string",
3333
"description":"a short version of the Accept header, e.g. json, yaml"
3434
},
35-
"local":{
36-
"type":"boolean",
37-
"description":"Return local information, do not retrieve the state from master node (default: false)"
38-
},
39-
"master_timeout":{
40-
"type":"time",
41-
"description":"Explicit operation timeout for connection to master node"
42-
},
4335
"h":{
4436
"type":"list",
4537
"description":"Comma-separated list of column names to display"

src/CodeGeneration/ApiGenerator/RestSpecification/Core/cat.fielddata.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@
4949
"pb"
5050
]
5151
},
52-
"local":{
53-
"type":"boolean",
54-
"description":"Return local information, do not retrieve the state from master node (default: false)"
55-
},
56-
"master_timeout":{
57-
"type":"time",
58-
"description":"Explicit operation timeout for connection to master node"
59-
},
6052
"h":{
6153
"type":"list",
6254
"description":"Comma-separated list of column names to display"

src/CodeGeneration/ApiGenerator/RestSpecification/Core/cat.health.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
"type":"string",
2121
"description":"a short version of the Accept header, e.g. json, yaml"
2222
},
23-
"local":{
24-
"type":"boolean",
25-
"description":"Return local information, do not retrieve the state from master node (default: false)"
26-
},
27-
"master_timeout":{
28-
"type":"time",
29-
"description":"Explicit operation timeout for connection to master node"
30-
},
3123
"h":{
3224
"type":"list",
3325
"description":"Comma-separated list of column names to display"
@@ -41,6 +33,19 @@
4133
"type":"list",
4234
"description":"Comma-separated list of column names or column aliases to sort by"
4335
},
36+
"time":{
37+
"type":"enum",
38+
"description":"The unit in which to display time values",
39+
"options":[
40+
"d (Days)",
41+
"h (Hours)",
42+
"m (Minutes)",
43+
"s (Seconds)",
44+
"ms (Milliseconds)",
45+
"micros (Microseconds)",
46+
"nanos (Nanoseconds)"
47+
]
48+
},
4449
"ts":{
4550
"type":"boolean",
4651
"description":"Set to false to disable timestamping",

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@
7878
"type":"list",
7979
"description":"Comma-separated list of column names or column aliases to sort by"
8080
},
81+
"time":{
82+
"type":"enum",
83+
"description":"The unit in which to display time values",
84+
"options":[
85+
"d (Days)",
86+
"h (Hours)",
87+
"m (Minutes)",
88+
"s (Seconds)",
89+
"ms (Milliseconds)",
90+
"micros (Microseconds)",
91+
"nanos (Nanoseconds)"
92+
]
93+
},
8194
"v":{
8295
"type":"boolean",
8396
"description":"Verbose mode. Display column headers",

src/CodeGeneration/ApiGenerator/RestSpecification/Core/cat.nodes.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@
1616
]
1717
},
1818
"params":{
19+
"bytes":{
20+
"type":"enum",
21+
"description":"The unit in which to display byte values",
22+
"options":[
23+
"b",
24+
"k",
25+
"kb",
26+
"m",
27+
"mb",
28+
"g",
29+
"gb",
30+
"t",
31+
"tb",
32+
"p",
33+
"pb"
34+
]
35+
},
1936
"format":{
2037
"type":"string",
2138
"description":"a short version of the Accept header, e.g. json, yaml"
@@ -45,6 +62,19 @@
4562
"type":"list",
4663
"description":"Comma-separated list of column names or column aliases to sort by"
4764
},
65+
"time":{
66+
"type":"enum",
67+
"description":"The unit in which to display time values",
68+
"options":[
69+
"d (Days)",
70+
"h (Hours)",
71+
"m (Minutes)",
72+
"s (Seconds)",
73+
"ms (Milliseconds)",
74+
"micros (Microseconds)",
75+
"nanos (Nanoseconds)"
76+
]
77+
},
4878
"v":{
4979
"type":"boolean",
5080
"description":"Verbose mode. Display column headers",

src/CodeGeneration/ApiGenerator/RestSpecification/Core/cat.pending_tasks.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
"type":"list",
4242
"description":"Comma-separated list of column names or column aliases to sort by"
4343
},
44+
"time":{
45+
"type":"enum",
46+
"description":"The unit in which to display time values",
47+
"options":[
48+
"d (Days)",
49+
"h (Hours)",
50+
"m (Minutes)",
51+
"s (Seconds)",
52+
"ms (Milliseconds)",
53+
"micros (Microseconds)",
54+
"nanos (Nanoseconds)"
55+
]
56+
},
4457
"v":{
4558
"type":"boolean",
4659
"description":"Verbose mode. Display column headers",

0 commit comments

Comments
 (0)